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 =
|
hostMetadata =
|
||||||
let
|
let
|
||||||
inherit (builtins) readDir concatMap attrNames;
|
fs = builtins.readDir ./.;
|
||||||
fs = readDir ./.;
|
inherit (builtins) concatMap attrNames;
|
||||||
hostNames = concatMap (x: if fs.${x} == "directory" then [ x ] else [ ]) (attrNames fs);
|
hostNames = concatMap (x: if fs.${x} == "directory" then [ x ] else [ ]) (attrNames fs);
|
||||||
in
|
in
|
||||||
map
|
builtins.listToAttrs (map
|
||||||
(hn: { name = hn; inherit (import (./. + "/${hn}")) hardware pkgs system; })
|
(hn: { name = hn; value = import (./. + "/${hn}"); })
|
||||||
hostNames;
|
hostNames);
|
||||||
|
|
||||||
hardwareModule = { pkgs, hardware }: (
|
hardwareModule = hardware: (
|
||||||
{
|
{
|
||||||
qemu = (x: { imports = [ "${x.modulesPath}/profiles/qemu-guest.nix" ]; });
|
qemu = (x: { imports = [ "${x.modulesPath}/profiles/qemu-guest.nix" ]; });
|
||||||
physical = pkgs.nixosModules.notDetected;
|
physical = (x: { imports = [ "${x.modulesPath}/installer/scan/not-detected.nix" ]; });
|
||||||
}
|
}
|
||||||
).${hardware};
|
).${hardware};
|
||||||
|
|
||||||
in
|
in
|
||||||
builtins.listToAttrs (
|
builtins.mapAttrs
|
||||||
map
|
(n: v:
|
||||||
(h:
|
let pkgs = { inherit unstable stable2009; }.${v.pkgs};
|
||||||
let pkgs = { inherit unstable stable2009; }.${h.pkgs};
|
|
||||||
in
|
in
|
||||||
{
|
pkgs.lib.nixosSystem {
|
||||||
name = h.name;
|
inherit (v) system;
|
||||||
value = pkgs.lib.nixosSystem {
|
|
||||||
system = h.system;
|
|
||||||
modules = [
|
modules = [
|
||||||
(sconfig)
|
(sconfig)
|
||||||
(./. + "/${h.name}/configuration.nix")
|
(./. + "/${n}/configuration.nix")
|
||||||
(hardwareModule { inherit pkgs; inherit (h) hardware; })
|
(hardwareModule v.hardware)
|
||||||
({ ... }: {
|
({ ... }: {
|
||||||
networking.hostName = h.name;
|
networking.hostName = n;
|
||||||
sconfig.flakes.enable = true;
|
sconfig.flakes.enable = true;
|
||||||
sconfig.flakes.rebuildPath = "github:buckley310/nixos-config";
|
sconfig.flakes.rebuildPath = "github:buckley310/nixos-config";
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
};
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
hostMetadata
|
hostMetadata
|
||||||
)
|
|
||||||
|
|
Loading…
Reference in a new issue