From 101b008a72f9be88007abf44b75fcd05cf1b78b1 Mon Sep 17 00:00:00 2001 From: Miran Bastaja Date: Sat, 2 Dec 2023 13:03:25 +0100 Subject: Refactor virt.nix and turn it into a shared module --- share/system/virt.nix | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 share/system/virt.nix (limited to 'share/system') diff --git a/share/system/virt.nix b/share/system/virt.nix new file mode 100644 index 0000000..0207064 --- /dev/null +++ b/share/system/virt.nix @@ -0,0 +1,33 @@ +{ 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; + }; + }; +} -- cgit v1.3.1