From 047397747d04d9663a82a1ccb5c6228257ecf1cb Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 4 Jul 2024 23:39:10 +0200 Subject: [PATCH 1/9] packages/void: init at 0.15.0+dev --- packages/projects.nix | 2 ++ packages/tools/void/default.nix | 53 +++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 packages/tools/void/default.nix diff --git a/packages/projects.nix b/packages/projects.nix index a5a7fd7..3170bab 100644 --- a/packages/projects.nix +++ b/packages/projects.nix @@ -46,6 +46,8 @@ searxng = pkgs.callPackage ./web-apps/searxng { inherit pins; }; stevenblack-hosts = pkgs.callPackage ./data/stevenblack { inherit pins; }; + + void = pkgs.callPackage ./tools/void { }; }; projectShells = { diff --git a/packages/tools/void/default.nix b/packages/tools/void/default.nix new file mode 100644 index 0000000..fc9b85c --- /dev/null +++ b/packages/tools/void/default.nix @@ -0,0 +1,53 @@ +{ lib, buildGoModule, fetchFromGitHub, installShellFiles }: + +let + version = "0.15.0+dev"; + rev = "6461b31e4458dbce655fa1db6d266f666dbdfc4e"; +in +buildGoModule rec { + + inherit version; + pname = "void"; + + meta = { + description = "Paisano CLI/TUI, customized for Private Void"; + license = lib.licenses.unlicense; + homepage = "https://github.com/paisano-nix/tui"; + }; + + src = fetchFromGitHub { + owner = "paisano-nix"; + repo = "tui"; + inherit rev; + hash = "sha256-EFDb8jfv2SH57a6CfDo0WU4XjDihhgvVnKKw20yqksc="; + }; + + postPatch = '' + substituteInPlace flake/flake.go --replace-fail __std lib.catalog + substituteInPlace env/env.go --replace-fail '"metadata"' '"void-cli-metadata"' + ''; + + sourceRoot = "source/src"; + + vendorHash = "sha256-S1oPselqHRIPcqDSsvdIkCwu1siQGRDHOkxWtYwa+g4="; + + nativeBuildInputs = [ installShellFiles ]; + + postInstall = '' + mv $out/bin/paisano $out/bin/void + + installShellCompletion --cmd void \ + --bash <($out/bin/void _carapace bash) \ + --fish <($out/bin/void _carapace fish) \ + --zsh <($out/bin/void _carapace zsh) + ''; + + ldflags = [ + "-s" + "-w" + "-X main.buildVersion=${version}" + "-X main.buildCommit=${rev}" + "-X main.argv0=void" + "-X main.project=Depot" + ]; +} -- 2.47.0 From f5bd160d85832efc67f0d7a7f7d265f3d2cc91ff Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 4 Jul 2024 23:39:47 +0200 Subject: [PATCH 2/9] devShells/default: add void cli --- packages/projects.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/projects.nix b/packages/projects.nix index 3170bab..edc0767 100644 --- a/packages/projects.nix +++ b/packages/projects.nix @@ -60,6 +60,7 @@ hci npins pin + void pkgs.deadnix pkgs.statix ]; -- 2.47.0 From efc86f6b139c89f2c9905911637d95db6b874937 Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 4 Jul 2024 23:46:20 +0200 Subject: [PATCH 3/9] lib: expose --- lib/part.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/part.nix b/lib/part.nix index e152399..a0d09e7 100644 --- a/lib/part.nix +++ b/lib/part.nix @@ -23,5 +23,8 @@ }); }; - config._module.args.depot = config; + config = { + _module.args.depot = config; + flake = { inherit (config) lib; }; + }; } -- 2.47.0 From 62ec584812958ac242b25a34c12ef2f558443452 Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 5 Jul 2024 20:54:59 +0200 Subject: [PATCH 4/9] gitignore: add .cache --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 06d79aa..6472b16 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ result result-* **/.direnv/ -.data/ \ No newline at end of file +.data/ +.cache/ -- 2.47.0 From 9bdaff208db7bcb3c38bd195d0b10240f4d77816 Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 5 Jul 2024 22:48:39 +0200 Subject: [PATCH 5/9] catalog: init --- catalog/part.nix | 10 ++++++++++ catalog/target.nix | 31 +++++++++++++++++++++++++++++++ flake.nix | 1 + 3 files changed, 42 insertions(+) create mode 100644 catalog/part.nix create mode 100644 catalog/target.nix diff --git a/catalog/part.nix b/catalog/part.nix new file mode 100644 index 0000000..cb6bcad --- /dev/null +++ b/catalog/part.nix @@ -0,0 +1,10 @@ +{ lib, ... }: + +{ + perSystem = { + options.catalog = lib.mkOption { + type = with lib.types; lazyAttrsOf (lazyAttrsOf (lazyAttrsOf (submodule ./target.nix))); + default = {}; + }; + }; +} diff --git a/catalog/target.nix b/catalog/target.nix new file mode 100644 index 0000000..e3f9d29 --- /dev/null +++ b/catalog/target.nix @@ -0,0 +1,31 @@ +{ lib, name, ... }: + +{ + options = { + description = lib.mkOption { + type = lib.types.str; + default = name; + }; + + actions = lib.mkOption { + type = with lib.types; lazyAttrsOf (submodule { + options = { + description = lib.mkOption { + type = lib.types.str; + default = name; + }; + + command = lib.mkOption { + type = lib.types.str; + }; + + packages = lib.mkOption { + type = with lib.types; listOf package; + default = []; + }; + }; + }); + default = {}; + }; + }; +} diff --git a/flake.nix b/flake.nix index 581b5ae..cb2f64b 100644 --- a/flake.nix +++ b/flake.nix @@ -20,6 +20,7 @@ ./jobs/part.nix ./lib/part.nix ./cluster/part.nix + ./catalog/part.nix ]; }; -- 2.47.0 From 986df6e838c980fdea6bdad2723d1eec0aeccdd0 Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 5 Jul 2024 22:49:10 +0200 Subject: [PATCH 6/9] lib/catalog: init --- lib/catalog.nix | 42 ++++++++++++++++++++++++++++++++++++++++++ lib/part.nix | 1 + 2 files changed, 43 insertions(+) create mode 100644 lib/catalog.nix diff --git a/lib/catalog.nix b/lib/catalog.nix new file mode 100644 index 0000000..b523fd4 --- /dev/null +++ b/lib/catalog.nix @@ -0,0 +1,42 @@ +{ config, lib, withSystem, ... }: + +{ + lib = { + catalog = { + init = lib.genAttrs config.systems (system: withSystem system ({ config, ... }: lib.mapAttrsToList (name: cell: { + cell = name; + cellBlocks = lib.mapAttrsToList (name: block: { + blockType = "catalogBlock"; + cellBlock = name; + targets = lib.mapAttrsToList (name: target: { + inherit name; + inherit (target) description; + actions = lib.mapAttrsToList (name: action: { + inherit name; + inherit (action) description; + }) target.actions; + }) block; + }) cell; + }) config.catalog)); + + actions = lib.genAttrs config.systems (system: withSystem system ({ config, pkgs, ... }: + lib.mapAttrs (name: cell: + lib.mapAttrs (name: block: + lib.mapAttrs (name: target: + lib.mapAttrs (name: action: + let + binPath = lib.makeBinPath action.packages; + in pkgs.writeShellScript name '' + # Void CLI Action + # --- + ${lib.optionalString (action.packages != []) ''export PATH="${binPath}:$PATH"''} + # --- + ${action.command} + '') target.actions + ) block + ) cell + ) + config.catalog)); + }; + }; +} diff --git a/lib/part.nix b/lib/part.nix index a0d09e7..9d259ad 100644 --- a/lib/part.nix +++ b/lib/part.nix @@ -7,6 +7,7 @@ ./meta.nix ./nginx.nix ./identity.nix + ./catalog.nix ]; options.lib = lib.mkOption { -- 2.47.0 From b8ff5d7d03711e677121f6149d35aa7ce30b3563 Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 5 Jul 2024 22:49:32 +0200 Subject: [PATCH 7/9] cluster/catalog: init --- cluster/catalog/default.nix | 52 +++++++++++++++++++++++++++++++++++++ cluster/part.nix | 4 +++ 2 files changed, 56 insertions(+) create mode 100644 cluster/catalog/default.nix diff --git a/cluster/catalog/default.nix b/cluster/catalog/default.nix new file mode 100644 index 0000000..82114b7 --- /dev/null +++ b/cluster/catalog/default.nix @@ -0,0 +1,52 @@ +{ config, lib, ... }: + +let + inherit (config) cluster flake; +in + +{ + perSystem = { config, pkgs, ... }: { + catalog.cluster = { + services = lib.mapAttrs (name: svc: { + description = "Cluster service: ${name}"; + actions = let + mkDeployAction = { description, agents }: { + inherit description; + packages = [ + config.packages.cachix + pkgs.tmux + ]; + command = let + cachixDeployJson = pkgs.writeText "cachix-deploy.json" (builtins.toJSON { + agents = lib.genAttrs agents (name: builtins.unsafeDiscardStringContext flake.nixosConfigurations.${name}.config.system.build.toplevel); + }); + in '' + set -e + echo building ${toString (lib.length agents)} configurations in parallel + tmux new-session ${lib.concatStringsSep " split-window " ( + map (host: let + drvPath = builtins.unsafeDiscardStringContext flake.nixosConfigurations.${host}.config.system.build.toplevel.drvPath; + in '' 'echo building configuration for ${host}; nix build -L --no-link --store "ssh-ng://${host}" --eval-store auto "${drvPath}^*"'\; '') agents + )} select-layout even-vertical + + source ~/.config/cachix/deploy + cachix deploy activate ${cachixDeployJson} + echo + ''; + }; + in { + deployAll = mkDeployAction { + description = "Deploy ALL groups of this service."; + agents = lib.unique (lib.concatLists (lib.attrValues svc.nodes)); + }; + } // lib.mapAttrs' (group: agents: { + name = "deployGroup-${group}"; + value = mkDeployAction { + description = "Deploy the '${group}' group of this service."; + inherit agents; + }; + }) svc.nodes; + }) cluster.config.services; + }; + }; +} diff --git a/cluster/part.nix b/cluster/part.nix index 99452ac..eae3222 100644 --- a/cluster/part.nix +++ b/cluster/part.nix @@ -1,6 +1,10 @@ { depot, lib, ... }: { + imports = [ + ./catalog + ]; + options.cluster = lib.mkOption { type = lib.types.raw; }; -- 2.47.0 From 986a8e8866d76e35382e9abf7ed382fdae37332b Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 5 Jul 2024 23:59:18 +0200 Subject: [PATCH 8/9] packages/catalog: init --- packages/catalog/checks.nix | 21 +++++++++++++++++++++ packages/catalog/default.nix | 5 +++++ packages/part.nix | 1 + 3 files changed, 27 insertions(+) create mode 100644 packages/catalog/checks.nix create mode 100644 packages/catalog/default.nix diff --git a/packages/catalog/checks.nix b/packages/catalog/checks.nix new file mode 100644 index 0000000..1dab997 --- /dev/null +++ b/packages/catalog/checks.nix @@ -0,0 +1,21 @@ +{ lib, ... }: + +{ + perSystem = { config, ... }: { + catalog.depot = { + checks = lib.mapAttrs (name: check: { + description = "NixOS Test: ${name}"; + actions = { + build = { + description = "Build this check."; + command = "nix build -L --no-link '${builtins.unsafeDiscardStringContext check.drvPath}^*'"; + }; + runInteractive = { + description = "Run interactive driver."; + command = lib.getExe check.driverInteractive; + }; + }; + }) config.checks; + }; + }; +} diff --git a/packages/catalog/default.nix b/packages/catalog/default.nix new file mode 100644 index 0000000..4a42cfa --- /dev/null +++ b/packages/catalog/default.nix @@ -0,0 +1,5 @@ +{ + imports = [ + ./checks.nix + ]; +} diff --git a/packages/part.nix b/packages/part.nix index 946dbb2..7823eae 100644 --- a/packages/part.nix +++ b/packages/part.nix @@ -8,6 +8,7 @@ in { imports = [ ./projects.nix ./patched-inputs.nix + ./catalog ]; perSystem = { pkgs, self', system, ... }: let patched-derivations = import ./patched-derivations.nix (pkgs // { flakePackages = self'.packages; }); -- 2.47.0 From 934d5fee0fabedff8f1bf16769b91d0b33e1f38b Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 6 Jul 2024 00:05:29 +0200 Subject: [PATCH 9/9] gitignore: add .nixos-test-history --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 6472b16..182b988 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ result-* **/.direnv/ .data/ .cache/ +.nixos-test-history -- 2.47.0