From bbafad8487233beab2803df6cc4a8d318a209ac5 Mon Sep 17 00:00:00 2001 From: Sean Buckley Date: Thu, 2 Dec 2021 16:04:13 -0500 Subject: [PATCH] move "nixosSystem" step out of getHosts --- flake.nix | 12 +++++++----- lib/hosts.nix | 31 ++++++++++++++++--------------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/flake.nix b/flake.nix index 73a2edb..9f87030 100644 --- a/flake.nix +++ b/flake.nix @@ -43,11 +43,13 @@ nixpkgs.overlays = [ (_: mypkgs) ]; }; - nixosConfigurations = getHosts { - path = ./hosts; - inherit nixpkgs; - inherit (self) nixosModule; - }; + nixosConfigurations = + builtins.mapAttrs + (_: nixpkgs.lib.nixosSystem) + (getHosts { + inherit (self) nixosModule; + path = ./hosts; + }); packages = forAllSystems (system: mypkgs nixpkgs.legacyPackages.${system}); diff --git a/lib/hosts.nix b/lib/hosts.nix index 6445fd2..43b1b22 100644 --- a/lib/hosts.nix +++ b/lib/hosts.nix @@ -1,4 +1,4 @@ -{ path, nixpkgs, nixosModule }: +{ path, nixosModule }: let inherit (builtins) mapAttrs attrValues attrNames readDir foldl' listToAttrs; @@ -17,18 +17,19 @@ let (system: hosts: listToAttrs (map (name: { inherit name; value = system; }) hosts)) sysToHosts)); - # build system configurations - # { host1 = ; host2 = ; } - hostToConfig = mapAttrs - (hostName: system: nixpkgs.lib.nixosSystem { - inherit system; - modules = [ - (nixosModule) - (path + "/${system}/${hostName}") - (_: { networking.hostName = hostName; }) - ]; - }) - hostToSys; - in -hostToConfig +# produce stub configurations + # { + # host1 = { system = "x86_64-linux"; modules = [ ... ]; }; + # host2 = { system = "x86_64-linux"; modules = [ ... ]; }; + # } +mapAttrs + (hostName: system: { + inherit system; + modules = [ + (nixosModule) + (path + "/${system}/${hostName}") + { networking = { inherit hostName; }; } + ]; + }) + hostToSys