nixos-config/lib/hosts.nix

45 lines
1.2 KiB
Nix
Raw Normal View History

2021-08-23 00:42:09 +00:00
{ path, nixosModule, unstable, ... }@inputs:
2021-06-05 06:22:38 +00:00
let
hostMetadata = builtins.mapAttrs
2021-08-23 00:42:09 +00:00
(name: _: import (path + "/${name}"))
(builtins.readDir path);
2021-06-05 06:22:38 +00:00
hardwareModules =
{
physical = (x: { imports = [ "${x.modulesPath}/installer/scan/not-detected.nix" ]; });
2021-07-13 14:55:27 +00:00
vmware = (x: {
virtualisation.vmware.guest.enable = true;
boot.initrd.availableKernelModules = [ "mptspi" ];
});
2021-06-05 06:22:38 +00:00
qemu = (x: {
services.qemuGuest.enable = true;
imports = [ "${x.modulesPath}/profiles/qemu-guest.nix" ];
});
};
getHostConfig = hostName: hostMeta:
2021-08-23 00:42:09 +00:00
inputs.${hostMeta.pkgs}.lib.nixosSystem
2021-06-05 06:22:38 +00:00
{
inherit (hostMeta) system;
modules = [
2021-08-23 00:42:09 +00:00
(nixosModule)
2021-06-05 06:22:38 +00:00
(hostMeta.module)
(hardwareModules.${hostMeta.hardware})
(_: { networking.hostName = hostName; })
2021-06-25 04:03:02 +00:00
(_: {
nixpkgs.overlays = [
2021-09-10 14:20:02 +00:00
(_: _: {
unstable = import unstable {
inherit (hostMeta) system;
config.allowUnfree = true;
};
})
2021-06-25 04:03:02 +00:00
];
})
2021-06-05 06:22:38 +00:00
];
};
in
builtins.mapAttrs getHostConfig hostMetadata