|
|
|
@ -48,7 +48,6 @@ let
|
|
|
|
|
-name ${config.system.name} \
|
|
|
|
|
-m ${toString config.virtualisation.memorySize} \
|
|
|
|
|
-smp ${toString config.virtualisation.cores} \
|
|
|
|
|
${concatStringsSep " " config.virtualisation.qemu.networkingOptions} \
|
|
|
|
|
${toString config.virtualisation.qemu.options} \
|
|
|
|
|
${
|
|
|
|
|
if config.hardware.genode.usb.storage.enable then
|
|
|
|
@ -128,7 +127,7 @@ in {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
virtualisation.vlans = mkOption {
|
|
|
|
|
default = [ 1 ];
|
|
|
|
|
default = [ ];
|
|
|
|
|
example = [ 1 2 ];
|
|
|
|
|
description = ''
|
|
|
|
|
Virtual networks to which the VM is connected. Each
|
|
|
|
@ -189,20 +188,42 @@ in {
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
networkingOptions = mkOption {
|
|
|
|
|
default = [
|
|
|
|
|
"-net nic,netdev=user.0,model=virtio"
|
|
|
|
|
"-netdev user,id=user.0\${QEMU_NET_OPTS:+,$QEMU_NET_OPTS}"
|
|
|
|
|
];
|
|
|
|
|
type = types.listOf types.str;
|
|
|
|
|
description = ''
|
|
|
|
|
Networking-related command-line options that should be passed to qemu.
|
|
|
|
|
The default is to use userspace networking (slirp).
|
|
|
|
|
|
|
|
|
|
If you override this option, be advised to keep
|
|
|
|
|
''${QEMU_NET_OPTS:+,$QEMU_NET_OPTS} (as seen in the default)
|
|
|
|
|
to keep the default runtime behaviour.
|
|
|
|
|
'';
|
|
|
|
|
nics = mkOption {
|
|
|
|
|
description = "QEMU network devices.";
|
|
|
|
|
default = { };
|
|
|
|
|
type = with lib.types;
|
|
|
|
|
attrsOf (submodule {
|
|
|
|
|
options = {
|
|
|
|
|
netdev = mkOption {
|
|
|
|
|
type = submodule {
|
|
|
|
|
options = {
|
|
|
|
|
kind = mkOption {
|
|
|
|
|
type = str;
|
|
|
|
|
default = "user";
|
|
|
|
|
};
|
|
|
|
|
settings = mkOption {
|
|
|
|
|
type = attrsOf str;
|
|
|
|
|
default = { };
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
device = mkOption {
|
|
|
|
|
type = submodule {
|
|
|
|
|
options = {
|
|
|
|
|
kind = mkOption {
|
|
|
|
|
type = str;
|
|
|
|
|
default = "virtio-net-pci";
|
|
|
|
|
};
|
|
|
|
|
settings = mkOption {
|
|
|
|
|
type = attrsOf str;
|
|
|
|
|
default = { };
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
diskInterface = mkOption {
|
|
|
|
@ -280,6 +301,15 @@ in {
|
|
|
|
|
])
|
|
|
|
|
(mkIf (cfg.bios != null) [ "-bios ${cfg.bios}/bios.bin" ])
|
|
|
|
|
(mkIf (!cfg.graphics) [ "-nographic" ])
|
|
|
|
|
(let
|
|
|
|
|
toFlags = bind:
|
|
|
|
|
{ kind, settings }:
|
|
|
|
|
lib.strings.concatStringsSep "," ([ "${kind},${bind}" ]
|
|
|
|
|
++ (lib.attrsets.mapAttrsToList (k: v: "${k}=${v}") settings));
|
|
|
|
|
in lib.attrsets.mapAttrsToList (id: nic: [
|
|
|
|
|
"-netdev ${toFlags "id=${id}" nic.netdev}"
|
|
|
|
|
"-device ${toFlags "netdev=${id}" nic.device}"
|
|
|
|
|
]) cfg.qemu.nics)
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
system.build.vm = pkgs.runCommand "nixos-vm" { preferLocalBuild = true; } ''
|
|
|
|
|