my nix configs for my servers and desktop
1{ config, lib, system, pkgs, modulesPath, inputs, ... }:
2
3{
4 programs.virt-manager.enable = true;
5 virtualisation.spiceUSBRedirection.enable = true;
6 virtualisation.libvirtd = {
7 enable = true;
8 qemu = {
9 package = pkgs.qemu_kvm;
10 runAsRoot = true;
11 swtpm.enable = true;
12 };
13 hooks.qemu = {
14 win11 = ./scripts/vm-win11-hook.sh;
15 };
16 };
17
18 systemd.services.libvirtd = {
19 path = let
20 env = pkgs.buildEnv {
21 name = "qemu-hook-env";
22 paths = with pkgs; [
23 bash
24 libvirt
25 kmod
26 systemd
27 ripgrep
28 sd
29 ];
30 };
31 in
32 [ env ];
33 };
34
35 users.extraUsers.regent.extraGroups = [ "libvirtd" ];
36}