From 11ddc9364068d3d2ffe75a6901d38b5cfe363f44 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Sun, 27 Feb 2022 22:48:16 +0100 Subject: [PATCH] Refactor network references --- configuration/data/nodes.nix | 4 +++- configuration/default.nix | 46 ++++++++++++++++++++++-------------- 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/configuration/data/nodes.nix b/configuration/data/nodes.nix index be7d31d..eff9ef1 100644 --- a/configuration/data/nodes.nix +++ b/configuration/data/nodes.nix @@ -1,4 +1,6 @@ -{ +let + injectHostnames = builtins.mapAttrs (hostname: attributes: { hostname = hostname; } // attributes); +in injectHostnames { "machine-workbot-01.cryto.net" = { friendlyName = "workbot"; ipv4 = "148.251.195.23"; diff --git a/configuration/default.nix b/configuration/default.nix index 92f1dc8..d334cb0 100644 --- a/configuration/default.nix +++ b/configuration/default.nix @@ -36,7 +36,9 @@ in { description = "Cryto"; }; - "machine-borg2-01.cryto.net" = { pkgs, lib, ... }: { + "machine-borg2-01.cryto.net" = let + self = nodes."machine-borg2-01.cryto.net"; + in { pkgs, lib, ... }: { system.stateVersion = "18.09"; networking.hostName = "machine-borg2-01"; @@ -47,9 +49,9 @@ in { presets.base presets.kvm ./hardware-configurations/machine-borg2-01.nix - (tincConfiguration { hostname = "machine-borg2-01.cryto.net"; nodes = nodes; }) - (trackSystemMetrics nodes."machine-borg2-01.cryto.net".internalIpv4) - (trackServiceMetrics nodes."machine-borg2-01.cryto.net".internalIpv4) + (tincConfiguration { hostname = self.hostname; nodes = nodes; }) + (trackSystemMetrics self.internalIpv4) + (trackServiceMetrics self.internalIpv4) ]; boot.loader.grub.device = lib.mkForce "/dev/vda"; @@ -101,7 +103,9 @@ in { }; }; - "machine-haless-03.cryto.net" = { pkgs, lib, config, ... }@args: { + "machine-haless-03.cryto.net" = let + self = nodes."machine-haless-03.cryto.net"; + in { pkgs, lib, config, ... }@args: { system.stateVersion = "19.03"; networking.hostName = "machine-haless-03"; @@ -109,9 +113,9 @@ in { presets.base presets.kvm ./hardware-configurations/machine-haless-03.nix - (tincConfiguration { hostname = "machine-haless-03.cryto.net"; nodes = nodes; }) - (trackSystemMetrics nodes."machine-haless-03.cryto.net".internalIpv4) - (trackServiceMetrics nodes."machine-haless-03.cryto.net".internalIpv4) + (tincConfiguration { hostname = self.hostname; nodes = nodes; }) + (trackSystemMetrics self.internalIpv4) + (trackServiceMetrics self.internalIpv4) (httpHealthChecks { both = [ "iomfats.cryto.net" @@ -226,7 +230,9 @@ in { }; }; - "machine-konjassiem-02.cryto.net" = { pkgs, lib, config, ... }@args: { + "machine-konjassiem-02.cryto.net" = let + self = nodes."machine-konjassiem-02.cryto.net"; + in { pkgs, lib, config, ... }@args: { system.stateVersion = "20.03"; networking.hostName = "machine-konjassiem-02"; @@ -234,9 +240,9 @@ in { presets.base presets.kvm ./hardware-configurations/machine-konjassiem-02.nix - (tincConfiguration { hostname = "machine-konjassiem-02.cryto.net"; nodes = nodes; }) - (trackSystemMetrics nodes."machine-konjassiem-02.cryto.net".internalIpv4) - (trackServiceMetrics nodes."machine-konjassiem-02.cryto.net".internalIpv4) + (tincConfiguration { hostname = self.hostname; nodes = nodes; }) + (trackSystemMetrics self.internalIpv4) + (trackServiceMetrics self.internalIpv4) (httpHealthChecks { both = [ "git.cryto.net" ]; }) @@ -373,7 +379,9 @@ in { }; }; - "machine-pikachu-02.cryto.net" = { pkgs, lib, config, ... }@args: { + "machine-pikachu-02.cryto.net" = let + self = nodes."machine-pikachu-02.cryto.net"; + in { pkgs, lib, config, ... }@args: { system.stateVersion = "19.03"; networking.hostName = "machine-pikachu-02"; @@ -381,20 +389,22 @@ in { presets.base presets.kvm ./hardware-configurations/machine-pikachu-02.nix - (tincConfiguration { hostname = "machine-pikachu-02.cryto.net"; nodes = nodes; }) - (trackSystemMetrics nodes."machine-pikachu-02.cryto.net".internalIpv4) - (trackServiceMetrics nodes."machine-pikachu-02.cryto.net".internalIpv4) + (tincConfiguration { hostname = self.hostname; nodes = nodes; }) + (trackSystemMetrics self.internalIpv4) + (trackServiceMetrics self.internalIpv4) ]; }; - "machine-workbot-01.cryto.net" = { pkgs, lib, config, ... }@args: { + "machine-workbot-01.cryto.net" = let + self = nodes."machine-workbot-01.cryto.net"; + in { pkgs, lib, config, ... }@args: { system.stateVersion = "18.03"; networking.hostName = "machine-workbot-01"; imports = [ presets.base ./hardware-configurations/machine-workbot-01.nix - (tincConfiguration { hostname = "machine-workbot-01.cryto.net"; nodes = nodes; }) + (tincConfiguration { hostname = self.hostname; nodes = nodes; }) (trackSystemMetrics "127.0.0.1") (trackServiceMetrics "127.0.0.1") (httpHealthChecks {