2024-01-29 21:21:15 +00:00
|
|
|
{ pkgs, config, lib, modulesPath, microvm, disko, agenix, machines, dns, ... }: {
|
2024-01-28 11:06:30 +00:00
|
|
|
imports = [
|
|
|
|
(modulesPath + "/installer/scan/not-detected.nix")
|
|
|
|
microvm.nixosModules.host
|
|
|
|
];
|
|
|
|
|
|
|
|
config = {
|
|
|
|
boot = {
|
|
|
|
kernelModules = [ "kvm-intel" ];
|
|
|
|
extraModulePackages = [ ];
|
|
|
|
|
|
|
|
initrd = {
|
|
|
|
availableKernelModules = [
|
|
|
|
"ahci"
|
|
|
|
"xhci_pci"
|
|
|
|
"nvme"
|
|
|
|
"usbhid"
|
|
|
|
"usb_storage"
|
|
|
|
"sd_mod"
|
|
|
|
"sdhci_pci"
|
|
|
|
];
|
|
|
|
kernelModules = [ ];
|
|
|
|
};
|
|
|
|
|
|
|
|
loader = {
|
|
|
|
systemd-boot.enable = true;
|
|
|
|
efi.canTouchEfiVariables = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
nixpkgs = {
|
|
|
|
config.allowUnfree = true;
|
|
|
|
hostPlatform = "x86_64-linux";
|
|
|
|
};
|
|
|
|
|
|
|
|
hardware.cpu.intel.updateMicrocode = config.hardware.enableRedistributableFirmware;
|
|
|
|
|
|
|
|
age.identityPaths = [ "/etc/age_ed25519" ];
|
|
|
|
|
|
|
|
nix = {
|
|
|
|
package = pkgs.nixFlakes;
|
|
|
|
extraOptions = ''
|
|
|
|
experimental-features = nix-command flakes
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
system = {
|
|
|
|
stateVersion = "23.05";
|
|
|
|
|
|
|
|
activationScripts.diff = ''
|
|
|
|
if [[ -e /run/current-system ]]; then
|
|
|
|
${pkgs.nix}/bin/nix store diff-closures /run/current-system "$systemConfig"
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
microvm.vms =
|
|
|
|
let
|
2024-01-28 11:55:58 +00:00
|
|
|
vmsForHypervisor = lib.filterAttrs (n: v: v.type == "virtual" && v.hypervisorName == config.networking.hostName) machines;
|
2024-01-28 11:06:30 +00:00
|
|
|
in
|
2024-01-28 11:55:58 +00:00
|
|
|
builtins.mapAttrs
|
|
|
|
(name: vm:
|
2024-01-28 11:06:30 +00:00
|
|
|
{
|
2024-01-28 11:55:58 +00:00
|
|
|
# TODO Simplify?
|
2024-01-29 21:21:15 +00:00
|
|
|
specialArgs = { inherit agenix disko pkgs lib microvm dns; machine = vm; hypervisorConfig = config; };
|
2024-01-28 13:08:28 +00:00
|
|
|
config.imports = [
|
|
|
|
./.
|
|
|
|
{ networking.hostName = name; }
|
|
|
|
];
|
2024-01-28 11:06:30 +00:00
|
|
|
}
|
|
|
|
)
|
2024-01-28 11:55:58 +00:00
|
|
|
vmsForHypervisor;
|
2024-01-28 11:06:30 +00:00
|
|
|
};
|
|
|
|
}
|