From 6ec7667c0af7f05f50545f3fc47b8e7b1fadae3d Mon Sep 17 00:00:00 2001 From: Astro Date: Wed, 8 Sep 2021 00:33:57 +0200 Subject: [PATCH] flake.nix: use more info from host-registry.nix --- flake.nix | 81 +++++++++++++++-------------------------------- host-registry.nix | 22 ++++++++++--- 2 files changed, 44 insertions(+), 59 deletions(-) diff --git a/flake.nix b/flake.nix index 41695bcf..04744bfc 100644 --- a/flake.nix +++ b/flake.nix @@ -42,8 +42,19 @@ }; extraHostRegistry = import ./host-registry.nix; hostRegistry = nixpkgs.lib.recursiveUpdate zwHostRegistry extraHostRegistry; - in { + flakifiedHosts = nixpkgs.lib.filterAttrs (_: { system ? null, ... }: system != null) hostRegistry.hosts; + + getHostAddr = name: + let + hostConf = hostRegistry.hosts.${name}; + in + if hostConf ? ip4 + then hostConf.ip4 + else if hostConf ? ip6 + then hostConf.ip6 + else null; + in { overlay = import ./overlay; legacyPackages = forAllSystems @@ -90,68 +101,28 @@ in { inherit (pkgs) bmxd; - glotzbert-nixos-rebuild = mkDeploy { name = "glotzbert"; }; - glotzbert-wake = mkWake "glotzbert"; + } // - pulsebert-nixos-rebuild = mkDeploy { - name = "pulsebert"; - builders = [ "ssh://client@172.22.99.110" ]; - }; - pulsebert-wake = mkWake "pulsebert"; + builtins.foldl' (result: host: result // { + "${host}-wake" = mkWake host; + }) {} (builtins.attrNames (nixpkgs.lib.filterAttrs (_: { wol ? false, ... }: wol) hostRegistry.hosts)) // - yggdrasil-nixos-rebuild = mkDeploy { - name = "yggdrasil"; - host = "172.20.72.62"; - }; - - freifunk-nixos-rebuild = mkDeploy { - name = "freifunk"; - host = "freifunk.core.zentralwerk.dn42"; - }; - - matemat-nixos-rebuild = mkDeploy { - name = "matemat"; - }; - - scrape-nixos-rebuild = mkDeploy { - name = "scrape"; - host = hostRegistry.hosts.scrape.ip4; - }; - - dn42-nixos-rebuild = mkDeploy { - name = "dn42"; - }; - - grafana-nixos-rebuild = mkDeploy { - name = "grafana"; - }; - - hydra-nixos-rebuild = mkDeploy { - name = "hydra"; - host = hostRegistry.hosts.hydra.ip4; - }; - - mucbot-nixos-rebuild = mkDeploy { - name = "mucbot"; - host = hostRegistry.hosts.mucbot.ip4; - }; - - kibana-nixos-rebuild = mkDeploy { - name = "kibana"; - host = hostRegistry.hosts.kibana.ip4; - }; - - public-access-proxy-nixos-rebuild = mkDeploy { - name = "public-access-proxy"; - host = hostRegistry.hosts.public-access-proxy.ip4; - }; - }); + builtins.foldl' (result: name: result // { + "${name}-nixos-rebuild" = mkDeploy ({ + inherit name; + host = getHostAddr name; + } // nixpkgs.lib.optionalAttrs (hostRegistry.hosts.${name} ? builders) { + inherit (hostRegistry.hosts.${name}) builders; + }); + }) {} (builtins.attrNames flakifiedHosts) + ); nixosConfigurations = let nixosSystem' = # Our custom NixOS builder { extraArgs ? {}, ... }@args: nixpkgs.lib.nixosSystem (args // { + #system = hostRegistry.${ extraArgs = extraArgs // { inherit hostRegistry; }; diff --git a/host-registry.nix b/host-registry.nix index 7fb2d1f4..fed2449a 100644 --- a/host-registry.nix +++ b/host-registry.nix @@ -2,8 +2,6 @@ rec { hosts = { - grafana.publicKey = - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPFB9fo01jzr2upEBEXiR7sSmeQoq9ll5Cf5/hjq5e4Y"; ledstripes.publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHRwhszG9T8ZWuSRkAupCPi7YDQBdaX0YzoQSsvCSpzC"; @@ -11,6 +9,8 @@ rec { ether = "ec:a8:6b:fe:b4:cb"; publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAnEWn/8CKIiCtehh6Ha3XUQqjODj0ygyo3aGAsFWgfG"; + system = "x86_64-linux"; + wol = true; }; mpd-index = { }; @@ -21,6 +21,9 @@ rec { ether = "dc:a6:32:31:b6:32"; publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIE9RKlt+mIew5epxHt7Gab44yFOdeD+L/EhhA6Ospzyq"; + system = "aarch64-linux"; + builders = [ "ssh://client@172.22.99.110" ]; + wol = true; }; samba = { }; storage-ng.publicKey = @@ -68,52 +71,63 @@ rec { ygg = "201:4561:bb58:4dac:5f6a:7b23:44f:a5ef"; publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHDmEymILp4IACjCbtMXx6eKPuTZHKyPUfAev05Gn7hi"; + system = "x86_64-linux"; }; freifunk = { ip4 = "172.20.72.40"; - ip6 = "2a00:8180:2c00:281:8000::1"; - publiKey = + publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMFbxHGfBMBjjior1FNRub56O62K++HVnqUH67BeKD7d"; + system = "x86_64-linux"; }; matemat = { ip4 = "172.22.99.133"; ip6 = "2a00:8180:2c00:223:f82b:1bff:fedc:8572"; publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBa07c4NnU1TGX1SMNea9e1d4nMtc0OS4gJLmTA3g/fe"; + system = "x86_64-linux"; }; scrape = { ip4 = "172.20.73.32"; ip6 = "2a00:8180:2c00:282:e073:50ff:fef5:eb6e"; publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEGxPgg6nswoij1fBzDPDu6h4+d458XL2+dBxAx9KVOh"; + system = "x86_64-linux"; }; dn42 = { ip4 = "172.22.99.253"; + system = "x86_64-linux"; }; grafana = { ip6 = "2a00:8180:2c00:282:4042:fbff:fe4b:2de8"; + publicKey = + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPFB9fo01jzr2upEBEXiR7sSmeQoq9ll5Cf5/hjq5e4Y"; + system = "x86_64-linux"; }; hydra = { ip4 = "172.20.73.49"; ip6 = "2a00:8180:2c00:282:e03c:d7ff:fe8e:fe16"; + system = "x86_64-linux"; }; mucbot = { ip4 = "172.20.73.27"; ip6 = "2a00:8180:2c00:282:28db:dff:fe6b:e89a"; + system = "x86_64-linux"; }; kibana = { ip4 = "172.20.73.44"; ip6 = "2a00:8180:2c00:282:460:7cff:fe28:76b2"; + system = "x86_64-linux"; }; public-access-proxy = { ip4 = "172.20.73.45"; ip6 = "2a00:8180:2c00:282:1024:5fff:febd:9be7"; + system = "x86_64-linux"; }; };