about summary refs log tree commit diff
path: root/modules/libvirtd.nix
blob: 484636409672f8638f9481e8a78a247d721a8e77 (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
54
55
56
{
  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 = {
        runAsRoot = false;

        package = pkgs.qemu_kvm;

        vhostUserPackages = [ pkgs.virtiofsd ];

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

        swtpm = {
          enable = true;
          package = pkgs.swtpm;
        };
      };
    };

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

Consider giving Nix/NixOS a try! <3