From a1f5e2acf7a02915da9eaffb33b15312c63385f3 Mon Sep 17 00:00:00 2001 From: Joakim Repomaa Date: Mon, 3 Mar 2025 11:29:51 +0200 Subject: [PATCH] allow building with nix build --- flake.nix | 67 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 29 deletions(-) diff --git a/flake.nix b/flake.nix index 475c9e6..1c20613 100644 --- a/flake.nix +++ b/flake.nix @@ -103,53 +103,62 @@ agenix.packages.${system}.default colmena.packages.${system}.colmena colmena.packages.${system}.manual - (pkgs.writeShellScriptBin "build" '' + (writeShellScriptBin "build" '' colmena --experimental-flake-eval build --keep-result "$@" '') - (pkgs.writeShellScriptBin "apply" '' + (writeShellScriptBin "apply" '' colmena --experimental-flake-eval apply --keep-result "$@" '') - (pkgs.writeShellScriptBin "apply-local" '' + (writeShellScriptBin "apply-local" '' colmena --experimental-flake-eval apply-local --sudo "$@" '') ]; }; }; flake = { - colmenaHive = colmena.lib.makeHive self.outputs.colmena; - - colmena = { - meta = { - inherit specialArgs; - - nixpkgs = import nixpkgs { - system = "x86_64-linux"; - overlays = [ ]; - }; + nixosConfigurations = + let + mkConfiguration = + name: + nixpkgs.lib.nixosSystem { + inherit specialArgs; + modules = [ + ./modules + ./hosts/${name} + ]; + }; + in + { + radish = mkConfiguration "radish"; + freun-dev = mkConfiguration "freun-dev"; + apu = mkConfiguration "apu"; }; - defaults = - { name, ... }: - { - imports = [ - ./modules - ./hosts/${name} - ]; - }; + colmenaHive = colmena.lib.makeHive self.outputs.colmena; - radish = - { ... }: - { - deployment = { + colmena = + let + deploymentOptions = { + radish = { allowLocalDeployment = true; targetHost = null; }; }; + in + { + meta = { + inherit specialArgs; - freun-dev = { ... }: { }; - - apu = { ... }: { }; - }; + nixpkgs = import nixpkgs { + system = "x86_64-linux"; + overlays = [ ]; + }; + }; + } + // builtins.mapAttrs (name: config: { + imports = config._module.args.modules; + deployment = if builtins.hasAttr name deploymentOptions then deploymentOptions.${name} else { }; + }) self.nixosConfigurations; }; } );