nixos-config/hosts/default.nix

46 lines
1.2 KiB
Nix
Raw Normal View History

2021-04-10 18:31:14 +00:00
{ sconfig, unstable, stable2009 }:
2021-04-06 03:11:17 +00:00
let
2021-04-06 03:24:24 +00:00
2021-04-10 16:55:17 +00:00
hostMetadata =
let
inherit (builtins) readDir concatMap attrNames;
fs = readDir ./.;
hostNames = concatMap (x: if fs.${x} == "directory" then [ x ] else [ ]) (attrNames fs);
in
map
(hn: { name = hn; inherit (import (./. + "/${hn}")) hardware pkgs system; })
hostNames;
2021-04-06 03:24:24 +00:00
2021-04-10 16:55:17 +00:00
hardwareModule = { pkgs, hardware }: (
{
qemu = (x: { imports = [ "${x.modulesPath}/profiles/qemu-guest.nix" ]; });
physical = pkgs.nixosModules.notDetected;
}
).${hardware};
2021-04-06 03:11:17 +00:00
in
2021-04-10 16:55:17 +00:00
builtins.listToAttrs (
map
(h:
let pkgs = { inherit unstable stable2009; }.${h.pkgs};
in
{
name = h.name;
value = pkgs.lib.nixosSystem {
system = h.system;
modules = [
2021-04-10 18:31:14 +00:00
(sconfig)
2021-04-10 16:55:17 +00:00
(./. + "/${h.name}/configuration.nix")
(hardwareModule { inherit pkgs; inherit (h) hardware; })
({ ... }: {
networking.hostName = h.name;
sconfig.flakes.enable = true;
sconfig.flakes.rebuildPath = "github:buckley310/nixos-config";
})
];
};
}
)
hostMetadata
)