From cbdbed109974109bc47a30092da29ff4781e19d8 Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Thu, 18 Apr 2024 15:53:20 +0200 Subject: [PATCH] feat(infra): Add nodeMeta argument --- hive.nix | 8 +++++--- modules/dgn-access-control.nix | 3 +-- modules/dgn-netbox-agent/default.nix | 9 ++++----- modules/dgn-network.nix | 3 ++- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/hive.nix b/hive.nix index 98e7fcf..07715f2 100644 --- a/hive.nix +++ b/hive.nix @@ -49,6 +49,8 @@ let }; meta = (import ./meta) lib; + + nodeMeta = meta.nodes.${node}; }; in @@ -64,7 +66,7 @@ in }; defaults = - { meta, name, ... }: + { name, nodeMeta, ... }: { # Import the default modules imports = [ ./modules ]; @@ -73,7 +75,7 @@ in age-secrets.sources = [ (./machines + "/${name}/secrets") ]; # Deployment config is specified in meta.nodes.${node}.deployment - inherit (meta.nodes.${name}) deployment; + inherit (nodeMeta) deployment; nix = { # Set NIX_PATH to the patched version of nixpkgs @@ -92,7 +94,7 @@ in # Use the stateVersion declared in the metadata system = { - inherit (meta.nodes.${name}) stateVersion; + inherit (nodeMeta) stateVersion; }; }; } diff --git a/modules/dgn-access-control.nix b/modules/dgn-access-control.nix index b94db79..375ea9c 100644 --- a/modules/dgn-access-control.nix +++ b/modules/dgn-access-control.nix @@ -35,7 +35,7 @@ config, lib, meta, - name, + nodeMeta, ... }: @@ -49,7 +49,6 @@ let types ; - nodeMeta = meta.nodes.${name}; admins = meta.organization.groups.root ++ nodeMeta.admins diff --git a/modules/dgn-netbox-agent/default.nix b/modules/dgn-netbox-agent/default.nix index 3c14ecc..49dcbe4 100644 --- a/modules/dgn-netbox-agent/default.nix +++ b/modules/dgn-netbox-agent/default.nix @@ -1,8 +1,7 @@ { config, - meta, - name, lib, + nodeMeta, ... }: let @@ -24,13 +23,13 @@ in register = true; update_all = true; virtual = { - enabled = meta.nodes.${name}.vm-cluster != null; - cluster_name = meta.nodes.${name}.vm-cluster; + enabled = nodeMeta.vm-cluster != null; + cluster_name = nodeMeta.vm-cluster; }; purge_old_devices = true; hostname_cmd = "echo ${hostName}.${domain}"; datacenter_location = { - driver = "cmd:echo ${meta.nodes.${name}.site}"; + driver = "cmd:echo ${nodeMeta.site}"; regex = "(.*)"; }; device = { diff --git a/modules/dgn-network.nix b/modules/dgn-network.nix index 19deac1..c3062a8 100644 --- a/modules/dgn-network.nix +++ b/modules/dgn-network.nix @@ -3,6 +3,7 @@ lib, meta, name, + nodeMeta, ... }: @@ -42,7 +43,7 @@ in inherit (net') hostId; hostName = name; - domain = "${meta.nodes.${name}.site}.infra.dgnum.eu"; + domain = "${nodeMeta.site}.infra.dgnum.eu"; useNetworkd = true; firewall.logRefusedConnections = false;