···325325 hydron = 298;
326326 cfssl = 299;
327327 cassandra = 300;
328328+ qemu-libvirtd = 301;
328329329330 # When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399!
330331···610611 hydron = 298;
611612 cfssl = 299;
612613 cassandra = 300;
614614+ qemu-libvirtd = 301;
613615614616 # When adding a gid, make sure it doesn't match an existing
615617 # uid. Users and groups with the same name should have equal
+24
nixos/modules/virtualisation/libvirtd.nix
···1717 ${optionalString cfg.qemuOvmf ''
1818 nvram = ["/run/libvirt/nix-ovmf/OVMF_CODE.fd:/run/libvirt/nix-ovmf/OVMF_VARS.fd"]
1919 ''}
2020+ ${optionalString (!cfg.qemuRunAsRoot) ''
2121+ user = "qemu-libvirtd"
2222+ group = "qemu-libvirtd"
2323+ ''}
2024 ${cfg.qemuVerbatimConfig}
2125 '';
2226···5660 '';
5761 };
58626363+ virtualisation.libvirtd.qemuRunAsRoot = mkOption {
6464+ type = types.bool;
6565+ default = true;
6666+ description = ''
6767+ If true, libvirtd runs qemu as root.
6868+ If false, libvirtd runs qemu as unprivileged user qemu-libvirtd.
6969+ Changing this option to false may cause file permission issues
7070+ for existing guests. To fix these, manually change ownership
7171+ of affected files in /var/lib/libvirt/qemu to qemu-libvirtd.
7272+ '';
7373+ };
7474+5975 virtualisation.libvirtd.qemuVerbatimConfig = mkOption {
6076 type = types.lines;
6177 default = ''
···109125 boot.kernelModules = [ "tun" ];
110126111127 users.groups.libvirtd.gid = config.ids.gids.libvirtd;
128128+129129+ # libvirtd runs qemu as this user and group by default
130130+ users.extraGroups.qemu-libvirtd.gid = config.ids.gids.qemu-libvirtd;
131131+ users.extraUsers.qemu-libvirtd = {
132132+ uid = config.ids.uids.qemu-libvirtd;
133133+ isNormalUser = false;
134134+ group = "qemu-libvirtd";
135135+ };
112136113137 systemd.packages = [ pkgs.libvirt ];
114138