flake.nix: use more info from host-registry.nix

This commit is contained in:
Astro 2021-09-08 00:33:57 +02:00
parent 49e70e393a
commit 6ec7667c0a
2 changed files with 44 additions and 59 deletions

View File

@ -42,8 +42,19 @@
}; };
extraHostRegistry = import ./host-registry.nix; extraHostRegistry = import ./host-registry.nix;
hostRegistry = nixpkgs.lib.recursiveUpdate zwHostRegistry extraHostRegistry; 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; overlay = import ./overlay;
legacyPackages = forAllSystems legacyPackages = forAllSystems
@ -90,68 +101,28 @@
in { in {
inherit (pkgs) bmxd; inherit (pkgs) bmxd;
glotzbert-nixos-rebuild = mkDeploy { name = "glotzbert"; }; } //
glotzbert-wake = mkWake "glotzbert";
pulsebert-nixos-rebuild = mkDeploy { builtins.foldl' (result: host: result // {
name = "pulsebert"; "${host}-wake" = mkWake host;
builders = [ "ssh://client@172.22.99.110" ]; }) {} (builtins.attrNames (nixpkgs.lib.filterAttrs (_: { wol ? false, ... }: wol) hostRegistry.hosts)) //
};
pulsebert-wake = mkWake "pulsebert";
yggdrasil-nixos-rebuild = mkDeploy { builtins.foldl' (result: name: result // {
name = "yggdrasil"; "${name}-nixos-rebuild" = mkDeploy ({
host = "172.20.72.62"; inherit name;
}; host = getHostAddr name;
} // nixpkgs.lib.optionalAttrs (hostRegistry.hosts.${name} ? builders) {
freifunk-nixos-rebuild = mkDeploy { inherit (hostRegistry.hosts.${name}) builders;
name = "freifunk"; });
host = "freifunk.core.zentralwerk.dn42"; }) {} (builtins.attrNames flakifiedHosts)
}; );
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;
};
});
nixosConfigurations = let nixosConfigurations = let
nixosSystem' = nixosSystem' =
# Our custom NixOS builder # Our custom NixOS builder
{ extraArgs ? {}, ... }@args: { extraArgs ? {}, ... }@args:
nixpkgs.lib.nixosSystem (args // { nixpkgs.lib.nixosSystem (args // {
#system = hostRegistry.${
extraArgs = extraArgs // { extraArgs = extraArgs // {
inherit hostRegistry; inherit hostRegistry;
}; };

View File

@ -2,8 +2,6 @@
rec { rec {
hosts = { hosts = {
grafana.publicKey =
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPFB9fo01jzr2upEBEXiR7sSmeQoq9ll5Cf5/hjq5e4Y";
ledstripes.publicKey = ledstripes.publicKey =
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHRwhszG9T8ZWuSRkAupCPi7YDQBdaX0YzoQSsvCSpzC"; "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHRwhszG9T8ZWuSRkAupCPi7YDQBdaX0YzoQSsvCSpzC";
@ -11,6 +9,8 @@ rec {
ether = "ec:a8:6b:fe:b4:cb"; ether = "ec:a8:6b:fe:b4:cb";
publicKey = publicKey =
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAnEWn/8CKIiCtehh6Ha3XUQqjODj0ygyo3aGAsFWgfG"; "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAnEWn/8CKIiCtehh6Ha3XUQqjODj0ygyo3aGAsFWgfG";
system = "x86_64-linux";
wol = true;
}; };
mpd-index = { }; mpd-index = { };
@ -21,6 +21,9 @@ rec {
ether = "dc:a6:32:31:b6:32"; ether = "dc:a6:32:31:b6:32";
publicKey = publicKey =
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIE9RKlt+mIew5epxHt7Gab44yFOdeD+L/EhhA6Ospzyq"; "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIE9RKlt+mIew5epxHt7Gab44yFOdeD+L/EhhA6Ospzyq";
system = "aarch64-linux";
builders = [ "ssh://client@172.22.99.110" ];
wol = true;
}; };
samba = { }; samba = { };
storage-ng.publicKey = storage-ng.publicKey =
@ -68,52 +71,63 @@ rec {
ygg = "201:4561:bb58:4dac:5f6a:7b23:44f:a5ef"; ygg = "201:4561:bb58:4dac:5f6a:7b23:44f:a5ef";
publicKey = publicKey =
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHDmEymILp4IACjCbtMXx6eKPuTZHKyPUfAev05Gn7hi"; "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHDmEymILp4IACjCbtMXx6eKPuTZHKyPUfAev05Gn7hi";
system = "x86_64-linux";
}; };
freifunk = { freifunk = {
ip4 = "172.20.72.40"; ip4 = "172.20.72.40";
ip6 = "2a00:8180:2c00:281:8000::1"; publicKey =
publiKey =
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMFbxHGfBMBjjior1FNRub56O62K++HVnqUH67BeKD7d"; "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMFbxHGfBMBjjior1FNRub56O62K++HVnqUH67BeKD7d";
system = "x86_64-linux";
}; };
matemat = { matemat = {
ip4 = "172.22.99.133"; ip4 = "172.22.99.133";
ip6 = "2a00:8180:2c00:223:f82b:1bff:fedc:8572"; ip6 = "2a00:8180:2c00:223:f82b:1bff:fedc:8572";
publicKey = publicKey =
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBa07c4NnU1TGX1SMNea9e1d4nMtc0OS4gJLmTA3g/fe"; "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBa07c4NnU1TGX1SMNea9e1d4nMtc0OS4gJLmTA3g/fe";
system = "x86_64-linux";
}; };
scrape = { scrape = {
ip4 = "172.20.73.32"; ip4 = "172.20.73.32";
ip6 = "2a00:8180:2c00:282:e073:50ff:fef5:eb6e"; ip6 = "2a00:8180:2c00:282:e073:50ff:fef5:eb6e";
publicKey = publicKey =
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEGxPgg6nswoij1fBzDPDu6h4+d458XL2+dBxAx9KVOh"; "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEGxPgg6nswoij1fBzDPDu6h4+d458XL2+dBxAx9KVOh";
system = "x86_64-linux";
}; };
dn42 = { dn42 = {
ip4 = "172.22.99.253"; ip4 = "172.22.99.253";
system = "x86_64-linux";
}; };
grafana = { grafana = {
ip6 = "2a00:8180:2c00:282:4042:fbff:fe4b:2de8"; ip6 = "2a00:8180:2c00:282:4042:fbff:fe4b:2de8";
publicKey =
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPFB9fo01jzr2upEBEXiR7sSmeQoq9ll5Cf5/hjq5e4Y";
system = "x86_64-linux";
}; };
hydra = { hydra = {
ip4 = "172.20.73.49"; ip4 = "172.20.73.49";
ip6 = "2a00:8180:2c00:282:e03c:d7ff:fe8e:fe16"; ip6 = "2a00:8180:2c00:282:e03c:d7ff:fe8e:fe16";
system = "x86_64-linux";
}; };
mucbot = { mucbot = {
ip4 = "172.20.73.27"; ip4 = "172.20.73.27";
ip6 = "2a00:8180:2c00:282:28db:dff:fe6b:e89a"; ip6 = "2a00:8180:2c00:282:28db:dff:fe6b:e89a";
system = "x86_64-linux";
}; };
kibana = { kibana = {
ip4 = "172.20.73.44"; ip4 = "172.20.73.44";
ip6 = "2a00:8180:2c00:282:460:7cff:fe28:76b2"; ip6 = "2a00:8180:2c00:282:460:7cff:fe28:76b2";
system = "x86_64-linux";
}; };
public-access-proxy = { public-access-proxy = {
ip4 = "172.20.73.45"; ip4 = "172.20.73.45";
ip6 = "2a00:8180:2c00:282:1024:5fff:febd:9be7"; ip6 = "2a00:8180:2c00:282:1024:5fff:febd:9be7";
system = "x86_64-linux";
}; };
}; };