diff --git a/flake.lock b/flake.lock
index 4308e9c..c1084e9 100644
--- a/flake.lock
+++ b/flake.lock
@@ -14,11 +14,11 @@
]
},
"locked": {
- "lastModified": 1707830867,
- "narHash": "sha256-PAdwm5QqdlwIqGrfzzvzZubM+FXtilekQ/FA0cI49/o=",
+ "lastModified": 1714136352,
+ "narHash": "sha256-BtWQ2Th/jamO1SlD+2ASSW5Jaf7JhA/JLpQHk0Goqpg=",
"owner": "ryantm",
"repo": "agenix",
- "rev": "8cb01a0e717311680e0cbca06a76cbceba6f3ed6",
+ "rev": "24a7ea390564ccd5b39b7884f597cfc8d7f6f44e",
"type": "github"
},
"original": {
@@ -73,11 +73,11 @@
]
},
"locked": {
- "lastModified": 1709336216,
- "narHash": "sha256-Dt/wOWeW6Sqm11Yh+2+t0dfEWxoMxGBvv3JpIocFl9E=",
+ "lastModified": 1714641030,
+ "narHash": "sha256-yzcRNDoyVP7+SCNX0wmuDju1NUCt8Dz9+lyUXEI0dbI=",
"owner": "hercules-ci",
"repo": "flake-parts",
- "rev": "f7b3c975cf067e56e7cda6cb098ebe3fb4d74ca2",
+ "rev": "e5d10a24b66c3ea8f150e47dfdb0416ab7c3390e",
"type": "github"
},
"original": {
@@ -136,11 +136,11 @@
]
},
"locked": {
- "lastModified": 1711604890,
- "narHash": "sha256-vbI/gxRTq/gHW1Q8z6D/7JG/qGNl3JTimUDX+MwnC3A=",
+ "lastModified": 1714679908,
+ "narHash": "sha256-KzcXzDvDJjX34en8f3Zimm396x6idbt+cu4tWDVS2FI=",
"owner": "nix-community",
"repo": "home-manager",
- "rev": "3142bdcc470e1e291e1fbe942fd69e06bd00c5df",
+ "rev": "9036fe9ef8e15a819fa76f47a8b1f287903fb848",
"type": "github"
},
"original": {
@@ -152,11 +152,11 @@
},
"nixpkgs": {
"locked": {
- "lastModified": 1711523803,
- "narHash": "sha256-UKcYiHWHQynzj6CN/vTcix4yd1eCu1uFdsuarupdCQQ=",
+ "lastModified": 1714635257,
+ "narHash": "sha256-4cPymbty65RvF1DWQfc+Bc8B233A1BWxJnNULJKQ1EY=",
"owner": "NixOS",
"repo": "nixpkgs",
- "rev": "2726f127c15a4cc9810843b96cad73c7eb39e443",
+ "rev": "63c3a29ca82437c87573e4c6919b09a24ea61b0f",
"type": "github"
},
"original": {
@@ -168,11 +168,11 @@
},
"nur": {
"locked": {
- "lastModified": 1711622043,
- "narHash": "sha256-nCNcHYlmmPPIDRkDCvNoEog+AuG7jdmkhkU0fqoS82A=",
+ "lastModified": 1714825428,
+ "narHash": "sha256-6U4cppyR0u6sqSSVr3GMrnIXhP2YGR0knfgrUGtr/1Y=",
"owner": "nix-community",
"repo": "NUR",
- "rev": "b7ff69e152caedbe4d0e40173d61732ac139a09c",
+ "rev": "5847f3365c16afafc10c56994beadd4cdc8552ee",
"type": "github"
},
"original": {
@@ -197,11 +197,11 @@
]
},
"locked": {
- "lastModified": 1711519547,
- "narHash": "sha256-Q7YmSCUJmDl71fJv/zD9lrOCJ1/SE/okZ2DsrmRjzhY=",
+ "lastModified": 1714478972,
+ "narHash": "sha256-q//cgb52vv81uOuwz1LaXElp3XAe1TqrABXODAEF6Sk=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
- "rev": "7d47a32e5cd1ea481fab33c516356ce27c8cef4a",
+ "rev": "2849da033884f54822af194400f8dff435ada242",
"type": "github"
},
"original": {
diff --git a/hosts/nixos/porthos/services.nix b/hosts/nixos/porthos/services.nix
index a67ae3b..23901f7 100644
--- a/hosts/nixos/porthos/services.nix
+++ b/hosts/nixos/porthos/services.nix
@@ -10,6 +10,11 @@ in
adblock = {
enable = true;
};
+ # Audiobook and podcast library
+ audiobookshelf = {
+ enable = true;
+ port = 9599;
+ };
# Backblaze B2 backup
backup = {
enable = true;
@@ -134,6 +139,7 @@ in
podgrab = {
enable = true;
passwordFile = secrets."podgrab/password".path;
+ dataDir = "/data/media/podcasts";
port = 9598;
};
# Regular backups
diff --git a/modules/home/direnv/default.nix b/modules/home/direnv/default.nix
index 93a1f3b..67beb62 100644
--- a/modules/home/direnv/default.nix
+++ b/modules/home/direnv/default.nix
@@ -7,9 +7,9 @@ in
enable = my.mkDisableOption "direnv configuration";
defaultFlake = mkOption {
- type = types.str;
- default = "pkgs";
- example = "nixpkgs";
+ type = with types; nullOr str;
+ default = null;
+ example = "pkgs";
description = ''
Which flake from the registry should be used for
use pkgs by default.
@@ -39,7 +39,7 @@ in
in
lib.my.genAttrs' files linkLibFile;
- home.sessionVariables = {
+ home.sessionVariables = lib.mkIf (cfg.defaultFlake != null) {
DIRENV_DEFAULT_FLAKE = cfg.defaultFlake;
};
};
diff --git a/modules/home/vim/after/ftplugin/bp.vim b/modules/home/vim/after/ftplugin/bp.vim
new file mode 100644
index 0000000..1224e7a
--- /dev/null
+++ b/modules/home/vim/after/ftplugin/bp.vim
@@ -0,0 +1,7 @@
+" Create the `b:undo_ftplugin` variable if it doesn't exist
+call ftplugined#check_undo_ft()
+
+" Add comment format
+setlocal comments=b://,s1:/*,mb:*,ex:*/
+setlocal commentstring=//\ %s
+let b:undo_ftplugin.='|setlocal comments< commentstring<'
diff --git a/modules/home/vim/after/ftplugin/json.vim b/modules/home/vim/after/ftplugin/json.vim
new file mode 100644
index 0000000..3f7b09d
--- /dev/null
+++ b/modules/home/vim/after/ftplugin/json.vim
@@ -0,0 +1,6 @@
+" Create the `b:undo_ftplugin` variable if it doesn't exist
+call ftplugined#check_undo_ft()
+
+" Use a small indentation value on JSON files
+setlocal shiftwidth=2
+let b:undo_ftplugin.='|setlocal shiftwidth<'
diff --git a/modules/home/vim/ftdetect/blueprint.lua b/modules/home/vim/ftdetect/blueprint.lua
new file mode 100644
index 0000000..d3fb395
--- /dev/null
+++ b/modules/home/vim/ftdetect/blueprint.lua
@@ -0,0 +1,6 @@
+-- Use `bp` filetype for Blueprint files
+vim.filetype.add({
+ extension = {
+ bp = "bp",
+ },
+})
diff --git a/modules/nixos/profiles/laptop/default.nix b/modules/nixos/profiles/laptop/default.nix
index 20a29d7..68c65b8 100644
--- a/modules/nixos/profiles/laptop/default.nix
+++ b/modules/nixos/profiles/laptop/default.nix
@@ -9,7 +9,7 @@ in
config = lib.mkIf cfg.enable {
# Enable touchpad support
- services.xserver.libinput.enable = true;
+ services.libinput.enable = true;
# Enable TLP power management
my.services.tlp.enable = true;
diff --git a/modules/nixos/services/audiobookshelf/default.nix b/modules/nixos/services/audiobookshelf/default.nix
new file mode 100644
index 0000000..8c9719d
--- /dev/null
+++ b/modules/nixos/services/audiobookshelf/default.nix
@@ -0,0 +1,39 @@
+# Audiobook and podcast library
+{ config, lib, ... }:
+let
+ cfg = config.my.services.audiobookshelf;
+in
+{
+ options.my.services.audiobookshelf = with lib; {
+ enable = mkEnableOption "Audiobookshelf, a self-hosted podcast manager";
+
+ port = mkOption {
+ type = types.port;
+ default = 8000;
+ example = 4242;
+ description = "The port on which Audiobookshelf will listen for incoming HTTP traffic.";
+ };
+ };
+
+ config = lib.mkIf cfg.enable {
+ services.audiobookshelf = {
+ enable = true;
+ inherit (cfg) port;
+
+ group = "media";
+ };
+
+ # Set-up media group
+ users.groups.media = { };
+
+ my.services.nginx.virtualHosts = {
+ audiobookshelf = {
+ inherit (cfg) port;
+ # Proxy websockets for RPC
+ extraConfig = {
+ locations."/".proxyWebsockets = true;
+ };
+ };
+ };
+ };
+}
diff --git a/modules/nixos/services/default.nix b/modules/nixos/services/default.nix
index 3b32d06..60b2478 100644
--- a/modules/nixos/services/default.nix
+++ b/modules/nixos/services/default.nix
@@ -4,6 +4,7 @@
imports = [
./adblock
./aria
+ ./audiobookshelf
./backup
./blog
./calibre-web
diff --git a/modules/nixos/services/nextcloud/default.nix b/modules/nixos/services/nextcloud/default.nix
index 51195df..bb3169a 100644
--- a/modules/nixos/services/nextcloud/default.nix
+++ b/modules/nixos/services/nextcloud/default.nix
@@ -31,7 +31,7 @@ in
config = lib.mkIf cfg.enable {
services.nextcloud = {
enable = true;
- package = pkgs.nextcloud28;
+ package = pkgs.nextcloud29;
hostName = "nextcloud.${config.networking.domain}";
home = "/var/lib/nextcloud";
maxUploadSize = cfg.maxSize;
diff --git a/modules/nixos/services/podgrab/default.nix b/modules/nixos/services/podgrab/default.nix
index 5ceebb6..ea89e4e 100644
--- a/modules/nixos/services/podgrab/default.nix
+++ b/modules/nixos/services/podgrab/default.nix
@@ -17,6 +17,15 @@ in
'';
};
+ dataDir = mkOption {
+ type = with types; nullOr str;
+ default = null;
+ example = "/mnt/podgrab";
+ description = ''
+ Path to the directory to store the podcasts. Use default if null
+ '';
+ };
+
port = mkOption {
type = types.port;
default = 8080;
@@ -29,8 +38,14 @@ in
services.podgrab = {
enable = true;
inherit (cfg) passwordFile port;
+
+ group = "media";
+ dataDirectory = lib.mkIf (cfg.dataDir != null) cfg.dataDir;
};
+ # Set-up media group
+ users.groups.media = { };
+
my.services.nginx.virtualHosts = {
podgrab = {
inherit (cfg) port;
diff --git a/modules/nixos/services/postgresql/default.nix b/modules/nixos/services/postgresql/default.nix
index 6f51f3e..bbe46d4 100644
--- a/modules/nixos/services/postgresql/default.nix
+++ b/modules/nixos/services/postgresql/default.nix
@@ -20,24 +20,28 @@ in
# Taken from the manual
(lib.mkIf cfg.upgradeScript {
- containers.temp-pg.config.services.postgresql = {
- enable = true;
- package = pkgs.postgresql_13;
- };
-
environment.systemPackages =
let
- newpg = config.containers.temp-pg.config.services.postgresql;
+ pgCfg = config.services.postgresql;
+ newPackage' = pkgs.postgresql_13;
+
+ oldPackage = if pgCfg.enableJIT then pgCfg.package.withJIT else pgCfg.package;
+ oldData = pgCfg.dataDir;
+ oldBin = "${if pgCfg.extraPlugins == [] then oldPackage else oldPackage.withPackages pgCfg.extraPlugins}/bin";
+
+ newPackage = if pgCfg.enableJIT then newPackage'.withJIT else newPackage';
+ newData = "/var/lib/postgresql/${newPackage.psqlSchema}";
+ newBin = "${if pgCfg.extraPlugins == [] then newPackage else newPackage.withPackages pgCfg.extraPlugins}/bin";
in
[
(pkgs.writeScriptBin "upgrade-pg-cluster" ''
#!/usr/bin/env bash
- set -x
- export OLDDATA="${config.services.postgresql.dataDir}"
- export NEWDATA="${newpg.dataDir}"
- export OLDBIN="${config.services.postgresql.package}/bin"
- export NEWBIN="${newpg.package}/bin"
+ set -eux
+ export OLDDATA="${oldData}"
+ export NEWDATA="${newData}"
+ export OLDBIN="${oldBin}"
+ export NEWBIN="${newBin}"
if [ "$OLDDATA" -ef "$NEWDATA" ]; then
echo "Cannot migrate to same data directory" >&2
@@ -46,14 +50,21 @@ in
install -d -m 0700 -o postgres -g postgres "$NEWDATA"
cd "$NEWDATA"
- sudo -u postgres $NEWBIN/initdb -D "$NEWDATA"
+ sudo -u postgres "$NEWBIN/initdb" -D "$NEWDATA"
systemctl stop postgresql # old one
- sudo -u postgres $NEWBIN/pg_upgrade \
+ sudo -u postgres "$NEWBIN/pg_upgrade" \
--old-datadir "$OLDDATA" --new-datadir "$NEWDATA" \
- --old-bindir $OLDBIN --new-bindir $NEWBIN \
+ --old-bindir "$OLDBIN" --new-bindir "$NEWBIN" \
"$@"
+
+ cat << EOF
+ Run the following commands after setting:
+ services.postgresql.package = pkgs.postgresql_${lib.versions.major newPackage.version}
+ sudo -u postgres vacuumdb --all --analyze-in-stages
+ ${newData}/delete_old_cluster.sh
+ EOF
'')
];
})
diff --git a/modules/nixos/services/rss-bridge/default.nix b/modules/nixos/services/rss-bridge/default.nix
index 85e37c2..52b1030 100644
--- a/modules/nixos/services/rss-bridge/default.nix
+++ b/modules/nixos/services/rss-bridge/default.nix
@@ -11,7 +11,9 @@ in
config = lib.mkIf cfg.enable {
services.rss-bridge = {
enable = true;
- whitelist = [ "*" ]; # Whitelist all
+ config = {
+ system.enabled_bridges = [ "*" ]; # Whitelist all
+ };
virtualHost = "rss-bridge.${config.networking.domain}";
};
diff --git a/modules/nixos/services/woodpecker/agent-exec/default.nix b/modules/nixos/services/woodpecker/agent-exec/default.nix
index 7ae21c8..24161b0 100644
--- a/modules/nixos/services/woodpecker/agent-exec/default.nix
+++ b/modules/nixos/services/woodpecker/agent-exec/default.nix
@@ -44,6 +44,8 @@ in
serviceConfig = {
# Same option as upstream, without @setuid
SystemCallFilter = lib.mkForce "~@clock @privileged @cpu-emulation @debug @keyring @module @mount @obsolete @raw-io @reboot @swap";
+ # NodeJS requires RWX memory...
+ MemoryDenyWriteExecute = lib.mkForce false;
BindPaths = [
"/nix/var/nix/daemon-socket/socket"
diff --git a/pkgs/bt-migrate/default.nix b/pkgs/bt-migrate/default.nix
deleted file mode 100644
index df99c55..0000000
--- a/pkgs/bt-migrate/default.nix
+++ /dev/null
@@ -1,61 +0,0 @@
-{ lib
-, boost
-, cmake
-, cxxopts
-, digestpp
-, fetchFromGitHub
-, fmt
-, jsoncons
-, pugixml
-, sqlite_orm
-, stdenv
-}:
-stdenv.mkDerivation {
- pname = "bt-migrate";
- version = "0-unstable-2023-08-17";
-
- src = fetchFromGitHub {
- owner = "mikedld";
- repo = "bt-migrate";
- rev = "e15a489c0c76f98355586ebbee08223af4e9bf50";
- hash = "sha256-kA6yxhbIh3ThmgF8Zyoe3I79giLVmdNr9IIrw5Xx4s0=";
- };
-
- nativeBuildInputs = [
- cmake
- ];
-
- buildInputs = [
- boost
- cxxopts
- fmt
- jsoncons
- pugixml
- sqlite_orm
- ];
-
- cmakeFlags = [
- (lib.strings.cmakeBool "USE_VCPKG" false)
- # NOTE: digestpp does not have proper CMake packaging (yet?)
- (lib.strings.cmakeBool "USE_FETCHCONTENT" true)
- (lib.strings.cmakeFeature "FETCHCONTENT_SOURCE_DIR_DIGESTPP" "${digestpp}/include/digestpp")
- ];
-
- # NOTE: no install target in CMake...
- installPhase = ''
- runHook preInstall
-
- mkdir -p $out/bin
- cp BtMigrate $out/bin
-
- runHook postInstall
- '';
-
- meta = with lib; {
- description = "Torrent state migration tool";
- homepage = "https://github.com/mikedld/bt-migrate";
- license = licenses.gpl3Only;
- maintainers = with maintainers; [ ambroisie ];
- mainProgram = "BtMigrate";
- };
-}
diff --git a/pkgs/default.nix b/pkgs/default.nix
index e82a90c..6b7fce1 100644
--- a/pkgs/default.nix
+++ b/pkgs/default.nix
@@ -1,7 +1,5 @@
{ pkgs }:
pkgs.lib.makeScope pkgs.newScope (pkgs: {
- bt-migrate = pkgs.callPackage ./bt-migrate { };
-
bw-pass = pkgs.callPackage ./bw-pass { };
change-audio = pkgs.callPackage ./change-audio { };
@@ -12,8 +10,6 @@ pkgs.lib.makeScope pkgs.newScope (pkgs: {
diff-flake = pkgs.callPackage ./diff-flake { };
- digestpp = pkgs.callPackage ./digestpp { };
-
dragger = pkgs.callPackage ./dragger { };
drone-rsync = pkgs.callPackage ./drone-rsync { };
@@ -30,8 +26,6 @@ pkgs.lib.makeScope pkgs.newScope (pkgs: {
rbw-pass = pkgs.callPackage ./rbw-pass { };
- sqlite_orm = pkgs.callPackage ./sqlite_orm { };
-
unbound-zones-adblock = pkgs.callPackage ./unbound-zones-adblock { };
zsh-done = pkgs.callPackage ./zsh-done { };
diff --git a/pkgs/digestpp/default.nix b/pkgs/digestpp/default.nix
deleted file mode 100644
index 2fd90db..0000000
--- a/pkgs/digestpp/default.nix
+++ /dev/null
@@ -1,31 +0,0 @@
-{ lib
-, fetchFromGitHub
-, stdenv
-}:
-stdenv.mkDerivation {
- pname = "digestpp";
- version = "0-unstable-2023-11-07";
-
- src = fetchFromGitHub {
- owner = "kerukuro";
- repo = "digestpp";
- rev = "ebb699402c244e22c3aff61d2239bcb2e87b8ef8";
- hash = "sha256-9X/P7DgZB6bSYjQWRli4iAXEFjhmACOVv3EYQrXuH5c=";
- };
-
- installPhase = ''
- runHook preInstall
-
- mkdir -p $out/include/digestpp
- cp -r *.hpp algorithm/ detail/ $out/include/digestpp
-
- runHook postInstall
- '';
-
- meta = with lib; {
- description = "C++11 header-only message digest library";
- homepage = "https://github.com/kerukuro/digestpp";
- license = licenses.unlicense;
- maintainers = with maintainers; [ ambroisie ];
- };
-}
diff --git a/pkgs/sqlite_orm/default.nix b/pkgs/sqlite_orm/default.nix
deleted file mode 100644
index 3891eee..0000000
--- a/pkgs/sqlite_orm/default.nix
+++ /dev/null
@@ -1,32 +0,0 @@
-{ lib
-, cmake
-, fetchFromGitHub
-, sqlite
-, stdenv
-}:
-stdenv.mkDerivation (finalAttrs: {
- pname = "sqlite_orm";
- version = "1.8.2";
-
- src = fetchFromGitHub {
- owner = "fnc12";
- repo = "sqlite_orm";
- rev = "v${finalAttrs.version}";
- hash = "sha256-KqphGFcnR1Y11KqL7sxODSv7lEvcURdF6kLd3cg84kc=";
- };
-
- nativeBuildInputs = [
- cmake
- ];
-
- propagatedBuildInputs = [
- sqlite
- ];
-
- meta = with lib; {
- description = "Light header only SQLite ORM";
- homepage = "https://sqliteorm.com/";
- license = licenses.agpl3Only; # MIT license is commercial
- maintainers = with maintainers; [ ambroisie ];
- };
-})
diff --git a/templates/c++-bazel/.bazelignore b/templates/c++-bazel/.bazelignore
new file mode 100644
index 0000000..6622ec1
--- /dev/null
+++ b/templates/c++-bazel/.bazelignore
@@ -0,0 +1,3 @@
+.pre-commit-config.yaml
+result
+.direnv
diff --git a/templates/c++-bazel/.bazelrc b/templates/c++-bazel/.bazelrc
new file mode 100644
index 0000000..0ef96ae
--- /dev/null
+++ b/templates/c++-bazel/.bazelrc
@@ -0,0 +1,6 @@
+# rule_nixpkgs' specific configuration
+build --host_platform=@io_tweag_rules_nixpkgs//nixpkgs/platforms:host
+build --crosstool_top=@nixpkgs_config_cc//:toolchain
+
+# Use C++20
+build:linux --cxxopt=-std=c++20
diff --git a/templates/c++-bazel/.clang-format b/templates/c++-bazel/.clang-format
new file mode 100644
index 0000000..19c58aa
--- /dev/null
+++ b/templates/c++-bazel/.clang-format
@@ -0,0 +1,23 @@
+# vim: ft=yaml
+---
+BasedOnStyle: LLVM
+IndentWidth: 4
+---
+Language: Cpp
+# Force pointers to the type for C++.
+DerivePointerAlignment: false
+PointerAlignment: Left
+
+# Short functions should not be on a single line, unless empty
+AllowShortFunctionsOnASingleLine: Empty
+
+# Make them level
+AccessModifierOffset: -4
+
+# It makes more sense this way
+BreakBeforeBinaryOperators: All
+BreakBeforeTernaryOperators: true
+
+# Aesthetic
+AlignOperands: AlignAfterOperator
+---
diff --git a/templates/c++-bazel/.envrc b/templates/c++-bazel/.envrc
new file mode 100644
index 0000000..de77fcb
--- /dev/null
+++ b/templates/c++-bazel/.envrc
@@ -0,0 +1,5 @@
+if ! has nix_direnv_version || ! nix_direnv_version 3.0.0; then
+ source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.0/direnvrc" "sha256-21TMnI2xWX7HkSTjFFri2UaohXVj854mgvWapWrxRXg="
+fi
+
+use flake
diff --git a/templates/c++-bazel/.gitignore b/templates/c++-bazel/.gitignore
new file mode 100644
index 0000000..84bd7c0
--- /dev/null
+++ b/templates/c++-bazel/.gitignore
@@ -0,0 +1,6 @@
+# Bazel build directories
+/bazel-*/
+
+# Nix generated files
+/.pre-commit-config.yaml
+/result
diff --git a/templates/c++-bazel/.woodpecker/check.yml b/templates/c++-bazel/.woodpecker/check.yml
new file mode 100644
index 0000000..4ff7dba
--- /dev/null
+++ b/templates/c++-bazel/.woodpecker/check.yml
@@ -0,0 +1,31 @@
+labels:
+ backend: local
+
+steps:
+- name: pre-commit check
+ image: bash
+ commands:
+ - nix develop --command pre-commit run --all
+
+- name: nix flake check
+ image: bash
+ commands:
+ - nix flake check
+
+- name: notifiy
+ image: bash
+ environment:
+ ADDRESS:
+ from_secret: matrix_homeserver
+ ROOM:
+ from_secret: matrix_roomid
+ USER:
+ from_secret: matrix_username
+ PASS:
+ from_secret: matrix_password
+ commands:
+ - nix run github:ambroisie/matrix-notifier
+ when:
+ status:
+ - failure
+ - success
diff --git a/templates/c++-bazel/BUILD b/templates/c++-bazel/BUILD
new file mode 100644
index 0000000..e69de29
diff --git a/templates/c++-bazel/WORKSPACE b/templates/c++-bazel/WORKSPACE
new file mode 100644
index 0000000..72d35b6
--- /dev/null
+++ b/templates/c++-bazel/WORKSPACE
@@ -0,0 +1,48 @@
+load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
+
+http_archive(
+ name = "io_tweag_rules_nixpkgs",
+ sha256 = "980edfceef2e59e1122d9be6c52413bc298435f0a3d452532b8a48d7562ffd67",
+ strip_prefix = "rules_nixpkgs-0.10.0",
+ urls = ["https://github.com/tweag/rules_nixpkgs/releases/download/v0.10.0/rules_nixpkgs-0.10.0.tar.gz"],
+)
+
+load("@io_tweag_rules_nixpkgs//nixpkgs:repositories.bzl", "rules_nixpkgs_dependencies")
+
+# load everything that rules_nixpkgs rules need to work
+rules_nixpkgs_dependencies()
+
+load("@io_tweag_rules_nixpkgs//nixpkgs:nixpkgs.bzl", "nixpkgs_cc_configure", "nixpkgs_local_repository")
+
+# Define nixpkgs version using the flakes lock file.
+nixpkgs_local_repository(
+ name = "nixpkgs",
+ nix_file_deps = ["//:flake.lock"],
+ nix_flake_lock_file = "//:flake.lock",
+)
+
+nixpkgs_cc_configure(
+ name = "nixpkgs_config_cc",
+ repository = "@nixpkgs",
+)
+
+# load rules_cc
+http_archive(
+ name = "rules_cc",
+ sha256 = "4dccbfd22c0def164c8f47458bd50e0c7148f3d92002cdb459c2a96a68498241",
+ urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.1/rules_cc-0.0.1.tar.gz"],
+)
+
+load("@rules_cc//cc:repositories.bzl", "rules_cc_dependencies", "rules_cc_toolchains")
+
+rules_cc_dependencies()
+
+rules_cc_toolchains()
+
+# Load dependencies
+http_archive(
+ name = "com_google_googletest",
+ sha256 = "8ad598c73ad796e0d8280b082cebd82a630d73e73cd3c70057938a6501bba5d7",
+ strip_prefix = "googletest-1.14.0",
+ urls = ["https://github.com/google/googletest/archive/refs/tags/v1.14.0.tar.gz"],
+)
diff --git a/templates/c++-bazel/flake.lock b/templates/c++-bazel/flake.lock
new file mode 100644
index 0000000..7440f4d
--- /dev/null
+++ b/templates/c++-bazel/flake.lock
@@ -0,0 +1,143 @@
+{
+ "nodes": {
+ "flake-compat": {
+ "flake": false,
+ "locked": {
+ "lastModified": 1673956053,
+ "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
+ "owner": "edolstra",
+ "repo": "flake-compat",
+ "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
+ "type": "github"
+ },
+ "original": {
+ "owner": "edolstra",
+ "repo": "flake-compat",
+ "type": "github"
+ }
+ },
+ "futils": {
+ "inputs": {
+ "systems": "systems"
+ },
+ "locked": {
+ "lastModified": 1694529238,
+ "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "ref": "main",
+ "repo": "flake-utils",
+ "type": "github"
+ }
+ },
+ "gitignore": {
+ "inputs": {
+ "nixpkgs": [
+ "pre-commit-hooks",
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1660459072,
+ "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=",
+ "owner": "hercules-ci",
+ "repo": "gitignore.nix",
+ "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73",
+ "type": "github"
+ },
+ "original": {
+ "owner": "hercules-ci",
+ "repo": "gitignore.nix",
+ "type": "github"
+ }
+ },
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1698134075,
+ "narHash": "sha256-foCD+nuKzfh49bIoiCBur4+Fx1nozo+4C/6k8BYk4sg=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "8efd5d1e283604f75a808a20e6cde0ef313d07d4",
+ "type": "github"
+ },
+ "original": {
+ "owner": "NixOS",
+ "ref": "nixos-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "nixpkgs-stable": {
+ "locked": {
+ "lastModified": 1685801374,
+ "narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "c37ca420157f4abc31e26f436c1145f8951ff373",
+ "type": "github"
+ },
+ "original": {
+ "owner": "NixOS",
+ "ref": "nixos-23.05",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "pre-commit-hooks": {
+ "inputs": {
+ "flake-compat": "flake-compat",
+ "flake-utils": [
+ "futils"
+ ],
+ "gitignore": "gitignore",
+ "nixpkgs": [
+ "nixpkgs"
+ ],
+ "nixpkgs-stable": "nixpkgs-stable"
+ },
+ "locked": {
+ "lastModified": 1698227354,
+ "narHash": "sha256-Fi5H9jbaQLmLw9qBi/mkR33CoFjNbobo5xWdX4tKz1Q=",
+ "owner": "cachix",
+ "repo": "pre-commit-hooks.nix",
+ "rev": "bd38df3d508dfcdff52cd243d297f218ed2257bf",
+ "type": "github"
+ },
+ "original": {
+ "owner": "cachix",
+ "ref": "master",
+ "repo": "pre-commit-hooks.nix",
+ "type": "github"
+ }
+ },
+ "root": {
+ "inputs": {
+ "futils": "futils",
+ "nixpkgs": "nixpkgs",
+ "pre-commit-hooks": "pre-commit-hooks"
+ }
+ },
+ "systems": {
+ "locked": {
+ "lastModified": 1681028828,
+ "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
+ "owner": "nix-systems",
+ "repo": "default",
+ "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nix-systems",
+ "repo": "default",
+ "type": "github"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/templates/c++-bazel/flake.nix b/templates/c++-bazel/flake.nix
new file mode 100644
index 0000000..63c64d6
--- /dev/null
+++ b/templates/c++-bazel/flake.nix
@@ -0,0 +1,126 @@
+{
+ description = "A C++ project";
+
+ inputs = {
+ futils = {
+ type = "github";
+ owner = "numtide";
+ repo = "flake-utils";
+ ref = "main";
+ };
+
+ nixpkgs = {
+ type = "github";
+ owner = "NixOS";
+ repo = "nixpkgs";
+ ref = "nixos-unstable";
+ };
+
+ pre-commit-hooks = {
+ type = "github";
+ owner = "cachix";
+ repo = "pre-commit-hooks.nix";
+ ref = "master";
+ inputs = {
+ flake-utils.follows = "futils";
+ nixpkgs.follows = "nixpkgs";
+ };
+ };
+ };
+
+ outputs = { self, futils, nixpkgs, pre-commit-hooks }:
+ {
+ overlays = {
+ default = final: _prev: {
+ project = with final; buildBazelPackage {
+ pname = "project";
+ version = "0.0.0";
+
+ src = self;
+
+ inherit (pkgs) bazel;
+
+ fetchAttrs = {
+ # Fixed output derivation hash after bazel fetch.
+ # This varies per platform, probably from the JDK pulled in being part
+ # of the output derivation ? Is there a more robust way to do this ?
+ # (Hashes extracted from the ofborg build logs)
+ sha256 = let inherit (stdenv.hostPlatform) system; in {
+ x86_64-linux = "${lib.fakeHash}";
+ }.${system} or (throw "No hash for system: ${system}");
+
+
+ # Use WORKSPACE file to fetch `rule_cc`
+ removeRulesCC = false;
+ };
+
+ buildAttrs = {
+ installPhase = ''
+ mkdir -p "$out/bin"
+
+ install bazel-bin/src/project "$out/bin"
+ '';
+ };
+
+ doCheck = true;
+
+ meta = with lib; {
+ description = "A C++ project";
+ homepage = "https://gitea.belanyi.fr/ambroisie/project";
+ license = licenses.mit;
+ maintainers = with maintainers; [ ambroisie ];
+ platforms = platforms.unix;
+ };
+ };
+ };
+ };
+ } // futils.lib.eachDefaultSystem (system:
+ let
+ pkgs = import nixpkgs {
+ inherit system;
+ overlays = [
+ self.overlays.default
+ ];
+ };
+
+ pre-commit = pre-commit-hooks.lib.${system}.run {
+ src = self;
+
+ hooks = {
+ nixpkgs-fmt = {
+ enable = true;
+ };
+
+ clang-format = {
+ enable = true;
+ };
+ };
+ };
+ in
+ {
+ checks = {
+ inherit (self.packages.${system}) project;
+
+ inherit pre-commit;
+ };
+
+ devShells = {
+ default = pkgs.mkShellNoCC {
+ inputsFrom = with self.packages.${system}; [
+ project
+ ];
+
+ packages = with pkgs; [
+ clang-tools
+ ];
+
+ inherit (pre-commit) shellHook;
+ };
+ };
+
+ packages = futils.lib.flattenTree {
+ default = pkgs.project;
+ inherit (pkgs) project;
+ };
+ });
+}
diff --git a/templates/c++-bazel/src/BUILD b/templates/c++-bazel/src/BUILD
new file mode 100644
index 0000000..a1b3dc9
--- /dev/null
+++ b/templates/c++-bazel/src/BUILD
@@ -0,0 +1,6 @@
+cc_binary(
+ name = "project",
+ srcs = [
+ "main.cc",
+ ],
+)
diff --git a/templates/c++-bazel/src/main.cc b/templates/c++-bazel/src/main.cc
new file mode 100644
index 0000000..5eb9e4a
--- /dev/null
+++ b/templates/c++-bazel/src/main.cc
@@ -0,0 +1,5 @@
+#include
+
+int main() {
+ std::cout << "Hello World!\n";
+}
diff --git a/templates/c++-bazel/tests/unit/BUILD b/templates/c++-bazel/tests/unit/BUILD
new file mode 100644
index 0000000..63ed0e5
--- /dev/null
+++ b/templates/c++-bazel/tests/unit/BUILD
@@ -0,0 +1,10 @@
+cc_test(
+ name = "dummy_test",
+ size = "small",
+ srcs = [
+ "dummy_test.cc",
+ ],
+ deps = [
+ "@com_google_googletest//:gtest_main",
+ ],
+)
diff --git a/templates/c++-bazel/tests/unit/dummy_test.cc b/templates/c++-bazel/tests/unit/dummy_test.cc
new file mode 100644
index 0000000..4573678
--- /dev/null
+++ b/templates/c++-bazel/tests/unit/dummy_test.cc
@@ -0,0 +1,5 @@
+#include
+
+TEST(misc, passing) {
+ ASSERT_EQ(1, 1);
+}
diff --git a/templates/default.nix b/templates/default.nix
index 31c3a81..44db753 100644
--- a/templates/default.nix
+++ b/templates/default.nix
@@ -7,4 +7,8 @@
path = ./c++-meson;
description = "A C++ project using Meson";
};
+ "rust-cargo" = {
+ path = ./rust-cargo;
+ description = "A Rust project using Cargo";
+ };
}
diff --git a/templates/rust-cargo/.envrc b/templates/rust-cargo/.envrc
new file mode 100644
index 0000000..de77fcb
--- /dev/null
+++ b/templates/rust-cargo/.envrc
@@ -0,0 +1,5 @@
+if ! has nix_direnv_version || ! nix_direnv_version 3.0.0; then
+ source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.0/direnvrc" "sha256-21TMnI2xWX7HkSTjFFri2UaohXVj854mgvWapWrxRXg="
+fi
+
+use flake
diff --git a/templates/rust-cargo/.gitignore b/templates/rust-cargo/.gitignore
new file mode 100644
index 0000000..5f360ff
--- /dev/null
+++ b/templates/rust-cargo/.gitignore
@@ -0,0 +1,6 @@
+# Rust build directory
+/target
+
+# Nix generated files
+/.pre-commit-config.yaml
+/result
diff --git a/templates/rust-cargo/.woodpecker/check.yml b/templates/rust-cargo/.woodpecker/check.yml
new file mode 100644
index 0000000..4ff7dba
--- /dev/null
+++ b/templates/rust-cargo/.woodpecker/check.yml
@@ -0,0 +1,31 @@
+labels:
+ backend: local
+
+steps:
+- name: pre-commit check
+ image: bash
+ commands:
+ - nix develop --command pre-commit run --all
+
+- name: nix flake check
+ image: bash
+ commands:
+ - nix flake check
+
+- name: notifiy
+ image: bash
+ environment:
+ ADDRESS:
+ from_secret: matrix_homeserver
+ ROOM:
+ from_secret: matrix_roomid
+ USER:
+ from_secret: matrix_username
+ PASS:
+ from_secret: matrix_password
+ commands:
+ - nix run github:ambroisie/matrix-notifier
+ when:
+ status:
+ - failure
+ - success
diff --git a/templates/rust-cargo/Cargo.lock b/templates/rust-cargo/Cargo.lock
new file mode 100644
index 0000000..4f9c86e
--- /dev/null
+++ b/templates/rust-cargo/Cargo.lock
@@ -0,0 +1,7 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "project"
+version = "0.0.0"
diff --git a/templates/rust-cargo/Cargo.toml b/templates/rust-cargo/Cargo.toml
new file mode 100644
index 0000000..4dfdc0b
--- /dev/null
+++ b/templates/rust-cargo/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "project"
+version = "0.0.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
diff --git a/templates/rust-cargo/flake.nix b/templates/rust-cargo/flake.nix
new file mode 100644
index 0000000..6d50369
--- /dev/null
+++ b/templates/rust-cargo/flake.nix
@@ -0,0 +1,112 @@
+{
+ description = "A Rust project";
+
+ inputs = {
+ futils = {
+ type = "github";
+ owner = "numtide";
+ repo = "flake-utils";
+ ref = "main";
+ };
+
+ nixpkgs = {
+ type = "github";
+ owner = "NixOS";
+ repo = "nixpkgs";
+ ref = "nixos-unstable";
+ };
+
+ pre-commit-hooks = {
+ type = "github";
+ owner = "cachix";
+ repo = "pre-commit-hooks.nix";
+ ref = "master";
+ inputs = {
+ flake-utils.follows = "futils";
+ nixpkgs.follows = "nixpkgs";
+ };
+ };
+ };
+
+ outputs = { self, futils, nixpkgs, pre-commit-hooks }:
+ {
+ overlays = {
+ default = final: _prev: {
+ project = with final; rustPlatform.buildRustPackage {
+ pname = "project";
+ version = (final.lib.importTOML ./Cargo.toml).package.version;
+
+ src = self;
+
+ cargoLock = {
+ lockFile = "${self}/Cargo.lock";
+ };
+
+ meta = with lib; {
+ description = "A Rust project";
+ homepage = "https://git.belanyi.fr/ambroisie/project";
+ license = licenses.mit;
+ maintainers = with maintainers; [ ambroisie ];
+ };
+ };
+ };
+ };
+ } // futils.lib.eachDefaultSystem (system:
+ let
+ pkgs = import nixpkgs {
+ inherit system;
+ overlays = [
+ self.overlays.default
+ ];
+ };
+
+ pre-commit = pre-commit-hooks.lib.${system}.run {
+ src = self;
+
+ hooks = {
+ clippy = {
+ enable = true;
+ settings = {
+ denyWarnings = true;
+ };
+ };
+
+ nixpkgs-fmt = {
+ enable = true;
+ };
+
+ rustfmt = {
+ enable = true;
+ };
+ };
+ };
+ in
+ {
+ checks = {
+ inherit (self.packages.${system}) project;
+ };
+
+ devShells = {
+ default = pkgs.mkShell {
+ inputsFrom = with self.packages.${system}; [
+ project
+ ];
+
+ packages = with pkgs; [
+ clippy
+ rust-analyzer
+ rustfmt
+ ];
+
+ RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
+
+ inherit (pre-commit) shellHook;
+ };
+ };
+
+ packages = futils.lib.flattenTree {
+ default = pkgs.project;
+ inherit (pkgs) project;
+ };
+ });
+}
diff --git a/templates/rust-cargo/rustfmt.toml b/templates/rust-cargo/rustfmt.toml
new file mode 100644
index 0000000..e69de29
diff --git a/templates/rust-cargo/src/main.rs b/templates/rust-cargo/src/main.rs
new file mode 100644
index 0000000..e7a11a9
--- /dev/null
+++ b/templates/rust-cargo/src/main.rs
@@ -0,0 +1,3 @@
+fn main() {
+ println!("Hello, world!");
+}