initial commit
This commit is contained in:
commit
ebc1be5217
143 changed files with 7721 additions and 0 deletions
63
modules/features/virtualization-libvirt.nix
Normal file
63
modules/features/virtualization-libvirt.nix
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
{ ... }:
|
||||
{
|
||||
config.dendritic.features.virtualization-libvirt = {
|
||||
nixosModules = [
|
||||
(
|
||||
{ config, pkgs, ... }:
|
||||
let
|
||||
user = config.dendritic.current.primaryUser;
|
||||
in
|
||||
{
|
||||
networking.firewall.trustedInterfaces = [ "virbr0" ];
|
||||
boot.kernelModules = [ "kvm-amd" ];
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
virt-manager
|
||||
virtiofsd
|
||||
vagrant
|
||||
];
|
||||
|
||||
users.users.${user} = {
|
||||
extraGroups = [
|
||||
"libvirtd"
|
||||
"qemu-libvirtd"
|
||||
"kvm"
|
||||
];
|
||||
};
|
||||
|
||||
# Allow VM to run as non-root without ulimit
|
||||
security.pam.loginLimits = [
|
||||
{
|
||||
domain = "${user}";
|
||||
type = "soft";
|
||||
item = "memlock";
|
||||
value = "20000000";
|
||||
}
|
||||
{
|
||||
domain = "${user}";
|
||||
type = "hard";
|
||||
item = "memlock";
|
||||
value = "20000000";
|
||||
}
|
||||
];
|
||||
|
||||
virtualisation.libvirtd = {
|
||||
enable = true;
|
||||
# qemu.ovmf.enable = true;
|
||||
# qemu.runAsRoot = false;
|
||||
onBoot = "ignore";
|
||||
onShutdown = "shutdown";
|
||||
qemu = {
|
||||
package = pkgs.qemu_kvm;
|
||||
runAsRoot = true;
|
||||
swtpm.enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
users.extraGroups.libvirtd.members = [ "${user}" ];
|
||||
|
||||
}
|
||||
)
|
||||
];
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue