summaryrefslogtreecommitdiff
path: root/accounts/gkleen@sif/libvirt/default.nix
blob: f86a68a2a0ea65bd3d969cd50e9422e5b7e8bb24 (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
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
{ flakeInputs, lib, pkgs, ... }:

with lib;
with flakeInputs.nixVirt.lib;

{
  config = {
    virtualisation.libvirt = {
      enable = true;
      connections."qemu:///session" = {
        domains = [
          { definition = domain.writeXML (updateManyAttrsByPath [
            ] (recursiveUpdate (domain.templates.windows {
              name = "lmmirzm-vmrz01";
              uuid = "9e1dab2e-7986-4cb3-88af-6fad8969e15f";
              memory = { count = 16; unit = "GiB"; };
              storage_vol = "/home/gkleen/.local/share/libvirt/images/lmmirzm-vmrz01.qcow2";
              nvram_path = "/home/gkleen/.local/share/libvirt/lmmirzm-vmrz01.nvram";
              virtio_drive = false;
              virtio_video = false;
              install_virtio = false;
            }) {
              qemu-commandline.env = [
                { name = "SPICE_DEBUG_ALLOW_MC"; value = "1"; }
              ];
              vcpu.count = 4;
              cpu = {
                mode = "host-model";
                feature = [
                  { name = "vmx"; policy = "require"; }
                ];
              };
              os.bootmenu.enable = true;
              devices.graphics = {
                listen.type = "address";
                # gl.enable = true;
              };
              devices.interface = {
                # model.type = "virtio";
                model.type = "e1000e";
                type = "bridge";
                mac.address = "52:54:00:b9:f3:ed";
                source.bridge = "rz-0971";
              };
              devices.channel = [
                {
                  type = "unix";
                  target = { type = "virtio"; name = "org.qemu.guest_agent.0"; };
                }
              ];
              devices.tpm.model = "tpm-tis";
            }));
          }
          { definition = domain.writeXML (recursiveUpdate (domain.templates.linux {
              name = "vmrz02";
              uuid = "daefc4b0-c48d-4b9d-a85d-7bd56eb068d0";
              memory = { count = 8; unit = "GiB"; };
              storage_vol = "/home/gkleen/.local/share/libvirt/images/vmrz02.qcow2";
              virtio_video = true;
            }) {
              os = {
                loader =
                  {
                    readonly = true;
                    type = "pflash";
                    path = "${pkgs.OVMFFull.fd}/FV/OVMF_CODE.ms.fd";
                  };
                nvram =
                  {
                    template = "${pkgs.OVMFFull.fd}/FV/OVMF_VARS.ms.fd";
                    path = "/home/gkleen/.local/share/libvirt/vmrz02.nvram";
                  };
                bootmenu.enable = true;
              };
              qemu-commandline.env = [
                { name = "SPICE_DEBUG_ALLOW_MC"; value = "1"; }
              ];
              vcpu.count = 4;
              cpu = {
                mode = "host-model";
                feature = [
                  { name = "vmx"; policy = "require"; }
                ];
              };
              devices.graphics = {
                listen.type = "address";
                gl.enable = false;
              };
              devices.video.model.acceleration.accel3d = false;
              devices.interface = [
                {
                  model.type = "virtio";
                  type = "bridge";
                  mac.address = "52:54:00:ec:d8:9d";
                  source.bridge = "rz-0971";
                }
                {
                  model.type = "virtio";
                  type = "bridge";
                  mac.address = "52:54:00:5e:f5:38";
                  source.bridge = "rz-2403";
                }
              ];
              devices.channel = [
                {
                  type = "unix";
                  target = { type = "virtio"; name = "org.qemu.guest_agent.0"; };
                }
                {
                  type = "spicevmc";
                  target = { type = "virtio"; name = "com.redhat.spice.0"; };
                }
                {
                  type = "spiceport";
                  target = { type = "virtio"; name = "org.spice-space.webdav.0"; };
                  source.channel = "org.spice-space.webdav.0";
                }
              ];
              devices.tpm = {
                model = "tpm-tis";
                backend =
                  {
                    type = "emulator";
                    version = "2.0";
                  };
              };
            });
          }
        ];
        pools = [
          { definition = pool.writeXML {
              type = "dir";
              name = "default";
              uuid = "ad899c92-02e3-45f9-bf49-195467aba2e2";
              target = {
                path = "/home/gkleen/.local/share/libvirt/images";
              };
            };
            active = true;
            volumes = [
              { definition = volume.writeXML {
                  type = "file";
                  name = "lmmirzm-vmrz01.qcow2";
                  capacity = { count = 40; unit = "GB"; };
                  target = {
                    path = "/home/gkleen/.local/share/libvirt/images/lmmirzm-vmrz01.qcow2";
                    format.type = "qcow2";
                    features.lazy_refcounts = {};
                  };
                };
              }
              { definition = volume.writeXML {
                  type = "file";
                  name = "vmrz02.qcow2";
                  capacity = { count = 256; unit = "GB"; };
                  target = {
                    path = "/home/gkleen/.local/share/libvirt/images/vmrz02.qcow2";
                    format.type = "qcow2";
                    features.lazy_refcounts = {};
                  };
                };
              }
            ];
          }
        ];
      };
    };
  };
}