about summary refs log tree commit diff
path: root/modules/nixos/libvirtd.nix
blob: 009fd2444f676e879a94a07f363dc576390d6449 (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
49
50
51
52
53
{
  config,
  lib,
  pkgs,
  ...
}:
with lib;
let
  cfg = config.nixfiles.modules.libvirtd;
in
{
  options.nixfiles.modules.libvirtd.enable = mkEnableOption "libvirtd";

  config = mkIf cfg.enable {
    ark.directories = [ "/var/lib/libvirt" ];

    hm.home.packages = with pkgs; [
      bridge-utils
      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 = true;
          package = pkgs.swtpm;
        };
      };
    };

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

Consider giving Nix/NixOS a try! <3