From 4ab025cdade91420fe8ecbbf594c474c534359fc Mon Sep 17 00:00:00 2001 From: clerie Date: Sun, 16 Apr 2023 16:37:11 +0200 Subject: [PATCH] flake.nix: Support different system types --- flake.nix | 55 ++++++++++++++++++++++---------------------- lib/flake-helper.nix | 9 ++++++-- 2 files changed, 34 insertions(+), 30 deletions(-) diff --git a/flake.nix b/flake.nix index 8582f56..3346f51 100644 --- a/flake.nix +++ b/flake.nix @@ -14,36 +14,35 @@ outputs = { self, nixpkgs, nixos-exporter, solid-xmpp-alarm, ... }@inputs: let helper = (import ./lib/flake-helper.nix) inputs; in { - nixosConfigurations = let - inherit (helper) - generateNixosSystem; - 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"; - dn42-ildix-service = generateNixosSystem "dn42-ildix-service"; - astatine = generateNixosSystem "astatine"; - _iso = generateNixosSystem "_iso"; + clerie.hosts = { + aluminium = { name = "aluminium"; }; + backup-4 = { name = "backup-4"; }; + beryllium = { name = "beryllium"; }; + carbon = { name = "carbon"; }; + clerie-backup = { name = "clerie-backup"; }; + dn42-il-gw1 = { name = "dn42-il-gw1"; }; + dn42-il-gw5 = { name = "dn42-il-gw5"; }; + dn42-il-gw6 = { name = "dn42-il-gw6"; }; + dn42-ildix-clerie = { name = "dn42-ildix-clerie"; }; + gatekeeper = { name = "gatekeeper"; }; + hydra-1 = { name = "hydra-1"; }; + hydra-2 = { name = "hydra-2"; }; + minecraft-2 = { name = "minecraft-2"; }; + monitoring-3 = { name = "monitoring-3"; }; + nonat = { name = "nonat"; }; + osmium = { name = "osmium"; }; + palladium = { name = "palladium"; }; + porter = { name = "porter"; }; + schule = { name = "schule"; }; + storage-2 = { name = "storage-2"; }; + web-2 = { name = "web-2"; }; + dn42-ildix-service = { name = "dn42-ildix-service"; }; + astatine = { name = "astatine"; }; + _iso = { name = "_iso"; }; }; + nixosConfigurations = helper.mapToNixosConfigurations self.clerie.hosts; + colmena = { meta = { nixpkgs = import nixpkgs {}; diff --git a/lib/flake-helper.nix b/lib/flake-helper.nix index 3fd2d33..7392887 100644 --- a/lib/flake-helper.nix +++ b/lib/flake-helper.nix @@ -1,10 +1,13 @@ { self, nixpkgs, nixos-exporter, solid-xmpp-alarm, ... }@inputs: rec { - generateNixosSystem = name: let + generateNixosSystem = { + name, + system ? "x86_64-linux", + }: let localNixpkgs = nixpkgs.lib.attrByPath [ "nixpkgs-${name}" ] nixpkgs inputs; in localNixpkgs.lib.nixosSystem { - system = "x86_64-linux"; + system = system; modules = [ ({ ... }: { /* @@ -28,6 +31,8 @@ rec { ]; }; + mapToNixosConfigurations = hosts: builtins.mapAttrs (name: host: generateNixosSystem host) hosts; + generateColmenaHost = name: hostSystem: { deployment = { targetHost = "${name}.net.clerie.de";