~ruther/nixos-config

ref: 509b41049b045885bde71c8eb68e4d665f7c00e8 nixos-config/modules/desktop/virtualisation/qemu.nix -rw-r--r-- 1.2 KiB
509b4104 — Frantisek Bohacek chore: remove unnecessary code, use modules instead of imports, split files 1 year, 3 days ago
                                                                                
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
#
# Qemu/KVM with virt-manager
#

{ config, pkgs, ... }:

{
  users.groups.libvirtd.members = [ "root" config.nixos-config.defaultUser ];
  users.groups.kvm.members = [ "root" config.nixos-config.defaultUser ];

  virtualisation = {
    libvirtd = {
      enable = true;
      qemu = {
        ovmf.enable = true;
        ovmf.packages = [ pkgs.OVMFFull.fd ];
        verbatimConfig = ''
         nvram = [ "${pkgs.OVMF}/FV/OVMF.fd:${pkgs.OVMF}/FV/OVMF_VARS.fd" ]
        '';
        swtpm.enable = true;
      };
    };
    spiceUSBRedirection.enable = true;        # USB passthrough
  };

  environment = {
    etc = {
      "ovmf/edk2-x86_64-secure-code.fd" = {
        source = config.virtualisation.libvirtd.qemu.package + "/share/qemu/edk2-x86_64-secure-code.fd";
      };

      "ovmf/edk2-i386-vars.fd" = {
        source = config.virtualisation.libvirtd.qemu.package + "/share/qemu/edk2-i386-vars.fd";
      };
    };

    systemPackages = with pkgs; [
      virt-manager
      virt-viewer
      qemu
      OVMF
      gvfs # Used for shared folders between Linux and Windows
      swtpm
    ];
  };

  services = { # Enable file sharing between OS
    gvfs.enable = true;
  };
}
Do not follow this link