Create module for vmdev
This commit is contained in:
@@ -16,5 +16,9 @@
|
||||
home = true;
|
||||
gnome.enable = true;
|
||||
tailscale.enable = true;
|
||||
vmdev = {
|
||||
enable = true;
|
||||
system = "intel";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
+1
-33
@@ -1,41 +1,13 @@
|
||||
{ pkgs, config, ... }:
|
||||
|
||||
{
|
||||
environment.systemPackages = with pkgs; [
|
||||
dmidecode
|
||||
guestfs-tools
|
||||
libguestfs
|
||||
OVMFFull
|
||||
packer
|
||||
virt-manager
|
||||
vmware-workstation
|
||||
vmfs-tools
|
||||
xorriso
|
||||
];
|
||||
|
||||
# Give my user access to the libvirtd process
|
||||
users.users.greg.extraGroups = [ "libvirtd" ];
|
||||
greg.vmdev.enable = true;
|
||||
|
||||
virtualisation = {
|
||||
libvirtd = {
|
||||
enable = true;
|
||||
onBoot = "ignore"; # Do not auto-restart VMs on boot, unless they are marked autostart
|
||||
qemu.ovmf.enable = true;
|
||||
};
|
||||
|
||||
virtualbox.host = {
|
||||
enable = true;
|
||||
enableExtensionPack = true;
|
||||
};
|
||||
|
||||
waydroid.enable = false;
|
||||
lxd.enable = false;
|
||||
};
|
||||
|
||||
users.extraGroups.vboxusers.members = [ "greg" ];
|
||||
|
||||
boot.extraModprobeConfig = "options kvm_amd nested=1";
|
||||
|
||||
systemd.services = {
|
||||
gitlab-runner = {
|
||||
conflicts = [ "libvirtd.service" ];
|
||||
@@ -47,10 +19,6 @@
|
||||
wantedBy = pkgs.lib.mkForce [];
|
||||
serviceConfig.User = "root";
|
||||
};
|
||||
libvirtd = {
|
||||
preStart = "${pkgs.kmod}/bin/modprobe kvm_amd";
|
||||
postStop = "${pkgs.kmod}/bin/rmmod kvm_amd kvm";
|
||||
};
|
||||
};
|
||||
|
||||
age.secrets.runner-reg.file = ../../secrets/gitlab/myself-vbox-runner-reg.age;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
./rpi4.nix
|
||||
./sway.nix
|
||||
./tailscale.nix
|
||||
./vmdev.nix
|
||||
];
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
{ pkgs, lib, config, ... }:
|
||||
|
||||
let
|
||||
cfg = config.greg.vmdev;
|
||||
in with lib;
|
||||
{
|
||||
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";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
environment.systemPackages = with pkgs; [
|
||||
dmidecode
|
||||
guestfs-tools
|
||||
libguestfs
|
||||
OVMFFull
|
||||
packer
|
||||
virt-manager
|
||||
xorriso
|
||||
];
|
||||
|
||||
users.users."${cfg.user}".extraGroups = [ "libvirtd" ];
|
||||
|
||||
# Enable the virtualisation services
|
||||
virtualisation = {
|
||||
libvirtd = {
|
||||
enable = true;
|
||||
onBoot = "ignore"; # Do not auto-restart VMs on boot, unless they are marked autostart
|
||||
qemu.ovmf.enable = true;
|
||||
};
|
||||
|
||||
virtualbox.host = {
|
||||
enable = true;
|
||||
enableExtensionPack = true;
|
||||
};
|
||||
};
|
||||
|
||||
# Configuration for vbox user performance
|
||||
users.extraGroups.vboxusers.members = [ cfg.user ];
|
||||
|
||||
boot.extraModprobeConfig = "options kvm_${cfg.system} nested=1";
|
||||
|
||||
# Configure the services more
|
||||
systemd.services = {
|
||||
libvirtd = {
|
||||
preStart = "${pkgs.kmod}/bin/modprobe kvm_${cfg.system}";
|
||||
postStop = "${pkgs.kmod}/bin/rmmod kvm_${cfg.system} kvm";
|
||||
conflicts = [ "vbox.service" ];
|
||||
};
|
||||
vbox = {
|
||||
preStart = "${pkgs.kmod}/bin/modprobe vboxdrv vboxnetadp vboxnetflt";
|
||||
postStop = "${pkgs.kmod}/bin/rmmod vboxnetadp vboxnetflt vboxdrv";
|
||||
conflicts = [ "libvirtd.service" ];
|
||||
unitConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = "yes";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user