mirror of
https://github.com/buckley310/nixos-config.git
synced 2024-12-21 19:24:15 +00:00
refactor hosts/default.nix
This commit is contained in:
parent
818011e3e8
commit
01851cb48e
1 changed files with 26 additions and 31 deletions
|
@ -3,43 +3,38 @@ let
|
|||
|
||||
hostMetadata =
|
||||
let
|
||||
inherit (builtins) readDir concatMap attrNames;
|
||||
fs = readDir ./.;
|
||||
fs = builtins.readDir ./.;
|
||||
inherit (builtins) concatMap attrNames;
|
||||
hostNames = concatMap (x: if fs.${x} == "directory" then [ x ] else [ ]) (attrNames fs);
|
||||
in
|
||||
map
|
||||
(hn: { name = hn; inherit (import (./. + "/${hn}")) hardware pkgs system; })
|
||||
hostNames;
|
||||
builtins.listToAttrs (map
|
||||
(hn: { name = hn; value = import (./. + "/${hn}"); })
|
||||
hostNames);
|
||||
|
||||
hardwareModule = { pkgs, hardware }: (
|
||||
hardwareModule = hardware: (
|
||||
{
|
||||
qemu = (x: { imports = [ "${x.modulesPath}/profiles/qemu-guest.nix" ]; });
|
||||
physical = pkgs.nixosModules.notDetected;
|
||||
physical = (x: { imports = [ "${x.modulesPath}/installer/scan/not-detected.nix" ]; });
|
||||
}
|
||||
).${hardware};
|
||||
|
||||
in
|
||||
builtins.listToAttrs (
|
||||
map
|
||||
(h:
|
||||
let pkgs = { inherit unstable stable2009; }.${h.pkgs};
|
||||
builtins.mapAttrs
|
||||
(n: v:
|
||||
let pkgs = { inherit unstable stable2009; }.${v.pkgs};
|
||||
in
|
||||
{
|
||||
name = h.name;
|
||||
value = pkgs.lib.nixosSystem {
|
||||
system = h.system;
|
||||
pkgs.lib.nixosSystem {
|
||||
inherit (v) system;
|
||||
modules = [
|
||||
(sconfig)
|
||||
(./. + "/${h.name}/configuration.nix")
|
||||
(hardwareModule { inherit pkgs; inherit (h) hardware; })
|
||||
(./. + "/${n}/configuration.nix")
|
||||
(hardwareModule v.hardware)
|
||||
({ ... }: {
|
||||
networking.hostName = h.name;
|
||||
networking.hostName = n;
|
||||
sconfig.flakes.enable = true;
|
||||
sconfig.flakes.rebuildPath = "github:buckley310/nixos-config";
|
||||
})
|
||||
];
|
||||
};
|
||||
}
|
||||
)
|
||||
hostMetadata
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue