Add docker, virtualization

This commit is contained in:
Ryan Pandya 2025-02-01 19:38:08 +00:00
parent 75a35714f2
commit d918a4ae44
4 changed files with 92 additions and 2 deletions

View File

@ -10,6 +10,6 @@
# ./pipewire
./theming
# ./users
# ./virtualization
./virtualization
];
}

View File

@ -0,0 +1,89 @@
{
lib,
config,
pkgs,
username,
vars,
...
}:
let
cfg = config.virtualization;
in
{
options = {
virtualization = {
enable = lib.mkEnableOption "Enable virtualization in NixOS & home-manager";
};
};
config = lib.mkIf cfg.enable {
environment = {
systemPackages = with pkgs; [
docker-compose
podlet
quickemu
spice
spice-protocol
virt-manager
virtiofsd
virtio-win
win-spice
];
};
services = {
spice-vdagentd.enable = true;
};
virtualisation = {
docker = {
enable = true;
enableOnBoot = true;
autoPrune = {
enable = true;
dates = "weekly";
};
defaultNetwork.settings.dns_enabled = true;
enableNvidia = if vars.nvidia then true else false;
};
libvirtd = {
# Make sure you run this once: "sudo virsh net-autostart default"
enable = true;
qemu = {
swtpm.enable = true;
ovmf.enable = true;
ovmf.packages = [ pkgs.OVMFFull.fd ];
};
};
spiceUSBRedirection.enable = true;
vmVariant = {
virtualisation = {
memorySize = 4096;
cores = 3;
};
};
};
users = {
users = {
${username} = {
extraGroups = [
"docker"
"libvirtd"
"podman"
];
# quadlets
autoSubUidGidRange = true;
linger = true;
};
};
};
home-manager.users.${username} = {
dconf.settings = {
"org/virt-manager/virt-manager/connections" = {
autoconnect = [ "qemu:///system" ];
uris = [ "qemu:///system" ];
};
};
};
};
}

View File

@ -68,7 +68,7 @@ in
secrets.enable = true;
syncthing.enable = true;
# users.enable = true;
# virtualization.enable = true;
virtualization.enable = false;
console = {
earlySetup = true;

View File

@ -18,6 +18,7 @@ in
config = lib.mkIf cfg.enable {
# Custom modules
base.enable = true;
virtualization.enable = true;
catppuccinTheming.enable = lib.mkForce false;
packages.enable = lib.mkForce false;