2024-10-19 01:19:59 -05:00
|
|
|
{
|
|
|
|
|
pkgs,
|
|
|
|
|
lib,
|
|
|
|
|
config,
|
|
|
|
|
...
|
|
|
|
|
}:
|
2024-07-13 02:37:17 -05:00
|
|
|
|
|
|
|
|
let
|
2024-10-03 11:26:39 -05:00
|
|
|
cfg = config.greg.vmdev;
|
|
|
|
|
in
|
|
|
|
|
with lib;
|
2024-07-13 02:37:17 -05:00
|
|
|
{
|
2024-10-03 11:26:39 -05:00
|
|
|
options = {
|
|
|
|
|
greg.vmdev = {
|
|
|
|
|
enable = mkEnableOption "Enable this system for VM development work";
|
|
|
|
|
user = mkOption {
|
|
|
|
|
default = "greg";
|
|
|
|
|
type = types.str;
|
|
|
|
|
description = "The user who will be doing VM dev";
|
|
|
|
|
};
|
|
|
|
|
system = mkOption {
|
|
|
|
|
default = "amd";
|
|
|
|
|
type = types.str;
|
|
|
|
|
description = "Kernel module type to install - amd, intel, etc";
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
2024-07-13 02:37:17 -05:00
|
|
|
|
2024-10-03 11:26:39 -05:00
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
|
dmidecode
|
2024-10-22 10:18:01 -05:00
|
|
|
#guestfs-tools
|
2024-10-03 11:26:39 -05:00
|
|
|
libguestfs
|
|
|
|
|
OVMFFull
|
2024-11-14 00:23:18 -06:00
|
|
|
nixos-generators
|
2024-10-03 11:26:39 -05:00
|
|
|
packer
|
2025-01-08 08:05:24 -06:00
|
|
|
swtpm
|
2024-10-03 11:26:39 -05:00
|
|
|
virt-manager
|
2025-01-08 08:05:24 -06:00
|
|
|
virtio-win
|
2024-10-03 11:26:39 -05:00
|
|
|
xorriso
|
|
|
|
|
];
|
2024-07-13 02:37:17 -05:00
|
|
|
|
2024-10-03 11:26:39 -05:00
|
|
|
users.users."${cfg.user}".extraGroups = [ "libvirtd" ];
|
2024-07-13 02:37:17 -05:00
|
|
|
|
2024-10-03 11:26:39 -05:00
|
|
|
# Enable the virtualisation services
|
|
|
|
|
virtualisation = {
|
|
|
|
|
libvirtd = {
|
|
|
|
|
enable = true;
|
|
|
|
|
onBoot = "ignore"; # Do not auto-restart VMs on boot, unless they are marked autostart
|
2025-01-08 08:05:24 -06:00
|
|
|
qemu = {
|
|
|
|
|
swtpm = {
|
|
|
|
|
enable = true;
|
|
|
|
|
package = pkgs.swtpm;
|
|
|
|
|
};
|
2025-01-07 10:58:24 -06:00
|
|
|
};
|
2024-10-03 11:26:39 -05:00
|
|
|
};
|
|
|
|
|
};
|
2024-07-13 02:37:17 -05:00
|
|
|
|
2024-10-03 11:26:39 -05:00
|
|
|
boot.extraModprobeConfig = "options kvm_${cfg.system} nested=1";
|
|
|
|
|
};
|
2024-07-13 02:37:17 -05:00
|
|
|
}
|