From 8d9744c902882a0df01e06c5e2f9602ff147efbe Mon Sep 17 00:00:00 2001 From: Mel Date: Wed, 13 Nov 2024 18:59:44 +0100 Subject: Expand `me` module argument for nicer usage patterns Signed-off-by: Mel --- flake.nix | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'flake.nix') diff --git a/flake.nix b/flake.nix index 3b0b980..f99f130 100644 --- a/flake.nix +++ b/flake.nix @@ -19,15 +19,31 @@ outputs = inputs @ { self, nixpkgs, nixpkgs-unstable, home-manager, ... }: let + tailnetName = "serval-moth"; + systems = { x86 = "x86_64-linux"; arm = "aarch64-linux"; }; - machines = with systems; [ - { name = "corsac"; system = x86; } - { name = "lapin"; system = arm; } - { name = "renard"; system = x86; } + mkMachines = let + mkMachine = m: { + inherit (m) name system; + tailscale = { + inherit (m.tailscale) ip; + domain = "${m.name}.${tailnetName}.ts.net"; + }; + }; + + mkIdentities = ms: current: + lib.genAttrs (lib.catAttrs "name" ms) (m: current.name == m); + + in machines: map (m: (mkMachine m) // (mkIdentities machines m)) machines; + + machines = with systems; mkMachines [ + { name = "corsac"; system = x86; tailscale.ip = "100.64.100.100"; } + { name = "lapin"; system = arm; tailscale.ip = "100.83.254.27"; } + { name = "renard"; system = x86; tailscale.ip = "100.75.17.75"; } ]; packageSetsForSystem = system: let @@ -45,7 +61,7 @@ inherit (machine) system; specialArgs = inputs // (packageSetsForSystem machine.system) // { - me = machine.name; + me = machine; security = import ./security.nix; util = import ./util.nix { inherit lib; }; }; -- cgit 1.4.1