mirror of
https://github.com/buckley310/nixos-config.git
synced 2024-12-21 19:24:15 +00:00
refactor getHosts
This commit is contained in:
parent
5e186adc86
commit
773b17cf07
2 changed files with 12 additions and 8 deletions
|
@ -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;
|
||||
|
|
|
@ -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}; })
|
||||
];
|
||||
})
|
||||
];
|
||||
|
|
Loading…
Reference in a new issue