From 60c17708acf9c97c2027f60d089b02d3d81412ac Mon Sep 17 00:00:00 2001 From: clerie Date: Sat, 31 Dec 2022 23:28:10 +0100 Subject: [PATCH] flake.nix: generate nixos systems with functions --- flake.nix | 149 +++++++++--------------------------------------------- 1 file changed, 25 insertions(+), 124 deletions(-) diff --git a/flake.nix b/flake.nix index c656e48..4903a5c 100644 --- a/flake.nix +++ b/flake.nix @@ -11,134 +11,35 @@ }; system = "x86_64-linux"; in { - nixosConfigurations = { - aluminium = nixpkgs.lib.nixosSystem { + nixosConfigurations = let + generateNixosSystem = name: nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ - ./hosts/aluminium/configuration.nix - ]; - }; - backup-4 = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ./hosts/backup-4/configuration.nix - ]; - }; - beryllium = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ./hosts/beryllium/configuration.nix - ]; - }; - carbon = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ./hosts/carbon/configuration.nix - ]; - }; - clerie-backup = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ./hosts/clerie-backup/configuration.nix - ]; - }; - dn42-il-gw1 = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ./hosts/dn42-il-gw1/configuration.nix - ]; - }; - dn42-il-gw5 = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ./hosts/dn42-il-gw5/configuration.nix - ]; - }; - dn42-il-gw6 = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ./hosts/dn42-il-gw6/configuration.nix - ]; - }; - dn42-ildix-clerie = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ./hosts/dn42-ildix-clerie/configuration.nix - ]; - }; - gatekeeper = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ./hosts/gatekeeper/configuration.nix - ]; - }; - hydra-1 = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ./hosts/hydra-1/configuration.nix - ]; - }; - hydra-2 = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ./hosts/hydra-2/configuration.nix - ]; - }; - minecraft-2 = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ./hosts/minecraft-2/configuration.nix - ]; - }; - monitoring-3 = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ./hosts/monitoring-3/configuration.nix - ]; - }; - nonat = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ./hosts/nonat/configuration.nix - ]; - }; - osmium = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ./hosts/osmium/configuration.nix - ]; - }; - palladium = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ./hosts/palladium/configuration.nix - ]; - }; - porter = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ./hosts/porter/configuration.nix - ]; - }; - schule = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ./configuration/common - ./hosts/schule/configuration.nix - ]; - }; - storage-2 = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ./hosts/storage-2/configuration.nix - ]; - }; - web-2 = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ./hosts/web-2/configuration.nix + (./hosts + "/${name}/configuration.nix") ]; }; + in { + aluminium = generateNixosSystem "aluminium"; + backup-4 = generateNixosSystem "backup-4"; + beryllium = generateNixosSystem "beryllium"; + carbon = generateNixosSystem "carbon"; + clerie-backup = generateNixosSystem "clerie-backup"; + dn42-il-gw1 = generateNixosSystem "dn42-il-gw1"; + dn42-il-gw5 = generateNixosSystem "dn42-il-gw5"; + dn42-il-gw6 = generateNixosSystem "dn42-il-gw6"; + dn42-ildix-clerie = generateNixosSystem "dn42-ildix-clerie"; + gatekeeper = generateNixosSystem "gatekeeper"; + hydra-1 = generateNixosSystem "hydra-1"; + hydra-2 = generateNixosSystem "hydra-2"; + minecraft-2 = generateNixosSystem "minecraft-2"; + monitoring-3 = generateNixosSystem "monitoring-3"; + nonat = generateNixosSystem "nonat"; + osmium = generateNixosSystem "osmium"; + palladium = generateNixosSystem "palladium"; + porter = generateNixosSystem "porter"; + schule = generateNixosSystem "schule"; + storage-2 = generateNixosSystem "storage-2"; + web-2 = generateNixosSystem "web-2"; }; colmena = {