refactor getHosts

This commit is contained in:
Sean Buckley 2021-08-22 20:42:09 -04:00
parent 5e186adc86
commit 773b17cf07
2 changed files with 12 additions and 8 deletions

View file

@ -3,7 +3,7 @@
inputs.unstable.url = "nixpkgs/nixos-unstable";
inputs.impermanence.url = "github:nix-community/impermanence";
outputs = { self, nixpkgs, impermanence, ... }@inputs:
outputs = { self, nixpkgs, unstable, impermanence, ... }:
let
mypkgs = pkgs:
{
@ -42,7 +42,11 @@
nixpkgs.overlays = [ (_: mypkgs) ];
};
nixosConfigurations = self.lib.getHosts inputs ./hosts;
nixosConfigurations = self.lib.getHosts {
path = ./hosts;
inherit nixpkgs unstable;
inherit (self) nixosModule;
};
lib = {
getHosts = import lib/hosts.nix;

View file

@ -1,9 +1,9 @@
callerInputs: hostsPath:
{ path, nixosModule, unstable, ... }@inputs:
let
hostMetadata = builtins.mapAttrs
(name: _: import (hostsPath + "/${name}"))
(builtins.readDir hostsPath);
(name: _: import (path + "/${name}"))
(builtins.readDir path);
hardwareModules =
{
@ -19,17 +19,17 @@ let
};
getHostConfig = hostName: hostMeta:
callerInputs.${hostMeta.pkgs}.lib.nixosSystem
inputs.${hostMeta.pkgs}.lib.nixosSystem
{
inherit (hostMeta) system;
modules = [
(callerInputs.self.nixosModule)
(nixosModule)
(hostMeta.module)
(hardwareModules.${hostMeta.hardware})
(_: { networking.hostName = hostName; })
(_: {
nixpkgs.overlays = [
(_: _: { unstable = callerInputs.unstable.legacyPackages.${hostMeta.system}; })
(_: _: { unstable = unstable.legacyPackages.${hostMeta.system}; })
];
})
];