nixos/vms: Make drives a list (for ordering)
This commit is contained in:
parent
6971048268
commit
128accbade
@ -13,7 +13,7 @@
|
|||||||
if config.my.build.isDevVM then "00:02.0" else "27:00.0";
|
if config.my.build.isDevVM then "00:02.0" else "27:00.0";
|
||||||
|
|
||||||
vmLVM = vm: lv: {
|
vmLVM = vm: lv: {
|
||||||
"${lv}" = {
|
name = lv;
|
||||||
backend = {
|
backend = {
|
||||||
driver = "host_device";
|
driver = "host_device";
|
||||||
filename = "/dev/ssds/vm-${vm}-${lv}";
|
filename = "/dev/ssds/vm-${vm}-${lv}";
|
||||||
@ -26,10 +26,9 @@
|
|||||||
};
|
};
|
||||||
frontend = "virtio-blk";
|
frontend = "virtio-blk";
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
installerDisk = {
|
installerDisk = {
|
||||||
installer = {
|
name = "installer";
|
||||||
backend = {
|
backend = {
|
||||||
driver = "file";
|
driver = "file";
|
||||||
filename = "${systems.installer.configuration.config.my.buildAs.iso}/iso/nixos-installer-devplayer0.iso";
|
filename = "${systems.installer.configuration.config.my.buildAs.iso}/iso/nixos-installer-devplayer0.iso";
|
||||||
@ -41,7 +40,6 @@
|
|||||||
bootindex = 1;
|
bootindex = 1;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
my = {
|
my = {
|
||||||
@ -58,12 +56,11 @@
|
|||||||
waitOnline = "no-carrier";
|
waitOnline = "no-carrier";
|
||||||
mac = "52:54:00:15:1a:53";
|
mac = "52:54:00:15:1a:53";
|
||||||
};
|
};
|
||||||
drives = mkMerge ([ ] ++ (optionals (!config.my.build.isDevVM) [
|
drives = [ ] ++ (optionals (!config.my.build.isDevVM) [
|
||||||
(vmLVM "estuary" "esp")
|
(vmLVM "estuary" "esp")
|
||||||
(vmLVM "estuary" "nix")
|
(vmLVM "estuary" "nix")
|
||||||
(vmLVM "estuary" "persist")
|
(vmLVM "estuary" "persist")
|
||||||
{ esp.frontendOpts.bootindex = 0; }
|
]);
|
||||||
]));
|
|
||||||
hostDevices."${wanBDF}" = { };
|
hostDevices."${wanBDF}" = { };
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -76,16 +73,12 @@
|
|||||||
memory = 65536;
|
memory = 65536;
|
||||||
networks.vms.mac = "52:54:00:27:3d:5c";
|
networks.vms.mac = "52:54:00:27:3d:5c";
|
||||||
cleanShutdown.timeout = 120;
|
cleanShutdown.timeout = 120;
|
||||||
drives = mkMerge ([
|
drives = [ ] ++ (optionals (!config.my.build.isDevVM) [
|
||||||
installerDisk
|
|
||||||
] ++ (optionals (!config.my.build.isDevVM) [
|
|
||||||
(vmLVM "shill" "esp")
|
(vmLVM "shill" "esp")
|
||||||
(vmLVM "shill" "nix")
|
(vmLVM "shill" "nix")
|
||||||
(vmLVM "shill" "persist")
|
(vmLVM "shill" "persist")
|
||||||
{
|
{
|
||||||
esp.frontendOpts.bootindex = 0;
|
name = "media";
|
||||||
|
|
||||||
media = {
|
|
||||||
backend = {
|
backend = {
|
||||||
driver = "host_device";
|
driver = "host_device";
|
||||||
filename = "/dev/hdds/media";
|
filename = "/dev/hdds/media";
|
||||||
@ -96,9 +89,8 @@
|
|||||||
discard = "unmap";
|
discard = "unmap";
|
||||||
};
|
};
|
||||||
frontend = "virtio-blk";
|
frontend = "virtio-blk";
|
||||||
};
|
|
||||||
}
|
}
|
||||||
]));
|
]);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -82,6 +82,7 @@ let
|
|||||||
|
|
||||||
driveOpts = with lib.types; {
|
driveOpts = with lib.types; {
|
||||||
options = {
|
options = {
|
||||||
|
name = mkOpt' str null "Drive name.";
|
||||||
backend = mkOpt' qemuOpts { } "Backend blockdev options.";
|
backend = mkOpt' qemuOpts { } "Backend blockdev options.";
|
||||||
|
|
||||||
format = mkOpt' qemuOpts { } "Format blockdev options.";
|
format = mkOpt' qemuOpts { } "Format blockdev options.";
|
||||||
@ -128,7 +129,7 @@ let
|
|||||||
});
|
});
|
||||||
default = { };
|
default = { };
|
||||||
};
|
};
|
||||||
drives = mkOpt' (attrsOf (submodule driveOpts)) { } "Drives to attach to VM.";
|
drives = mkOpt' (listOf (submodule driveOpts)) { } "Drives to attach to VM.";
|
||||||
hostDevices = mkOpt' (attrsOf (submodule hostDevOpts)) { } "Host PCI devices to pass to the VM.";
|
hostDevices = mkOpt' (attrsOf (submodule hostDevOpts)) { } "Host PCI devices to pass to the VM.";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -170,10 +171,10 @@ let
|
|||||||
"netdev tap,id=${nn},ifname=${c.ifname},script=no"
|
"netdev tap,id=${nn},ifname=${c.ifname},script=no"
|
||||||
("device ${c.model},netdev=${nn},mac=${c.mac}" + (extraQEMUOpts c.extraOptions))
|
("device ${c.model},netdev=${nn},mac=${c.mac}" + (extraQEMUOpts c.extraOptions))
|
||||||
]) i.networks)) ++
|
]) i.networks)) ++
|
||||||
(flatten (mapAttrsToList (dn: c: [
|
(flatten (map (d: [
|
||||||
"blockdev node-name=${dn}-backend,${c.backend}"
|
"blockdev node-name=${d.name}-backend,${d.backend}"
|
||||||
"blockdev node-name=${dn}-format,${c.formatBackendProp}=${dn}-backend,${c.format}"
|
"blockdev node-name=${d.name}-format,${d.formatBackendProp}=${d.name}-backend,${d.format}"
|
||||||
("device ${c.frontend},id=${dn},drive=${dn}-format" + (extraQEMUOpts c.frontendOpts))
|
("device ${d.frontend},id=${d.name},drive=${d.name}-format" + (extraQEMUOpts d.frontendOpts))
|
||||||
]) i.drives)) ++
|
]) i.drives)) ++
|
||||||
(map (bdf: "device vfio-pci,host=${bdf}") (attrNames i.hostDevices));
|
(map (bdf: "device vfio-pci,host=${bdf}") (attrNames i.hostDevices));
|
||||||
args = map (v: "-${v}") flags;
|
args = map (v: "-${v}") flags;
|
||||||
|
Loading…
Reference in New Issue
Block a user