about summary refs log tree commit diff
path: root/modules/nixos/libvirtd.nix
blob: 58dfc50d13020dfe938f631c14f1f4c23c44bad5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
{
  config,
  lib,
  pkgs,
  ...
}:
with lib; let
  cfg = config.nixfiles.modules.libvirtd;
in {
  options.nixfiles.modules.libvirtd.enable = mkEnableOption "libvirtd";

  config = mkIf cfg.enable {
    hm.home.packages = with pkgs; [
      qemu-utils
      quickemu
      virt-manager
    ];

    virtualisation.libvirtd = {
      enable = true;

      onBoot = "ignore";
      onShutdown = "shutdown";

      extraConfig = ''
        log_level = 4
        log_outputs = "4:stderr"
      '';

      qemu = {
        package = pkgs.qemu_kvm;
        runAsRoot = false;

        ovmf = {
          enable = true;
          packages = [pkgs.OVMFFull.fd];
        };

        swtpm = {
          enable = false; # Is this required for Windows 11?
          package = pkgs.swtpm-tpm2;
        };
      };
    };

    my.extraGroups = ["libvirtd"];
  };
}

Consider giving Nix/NixOS a try! <3