aboutsummaryrefslogtreecommitdiff
path: root/share/system/virt.nix
blob: 6f5a9fee8c3ec567913eb60ba4de3b13835d31e2 (plain)
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
{ pkgs, virt-users ? [ ], ... }:
let
  # https://stackoverflow.com/questions/75855410/nix-map-list-of-keys-to-attribute-set-members
  attrSetRepeatValue = value: list:
    let acc = { }; # accumulator
    in builtins.foldl' (acc: key: acc // { "${key}" = value; }) acc list;
in {
  users.users = attrSetRepeatValue { extraGroups = [ "libvirtd" ]; } virt-users;

  home-manager.users = attrSetRepeatValue {
    home.packages = [ pkgs.quickemu ];
    dconf.settings."org/virt-manager/virt-manager/connections" = {
      autoconnect = [ "qemu:///system" ];
      uris = [ "qemu:///system" ];
    };
  } virt-users;

  programs.virt-manager.enable = true;
  virtualisation.libvirtd = {
    enable = true;
    qemu = {
      package = pkgs.qemu_kvm;
      swtpm.enable = true;
    };
  };
}