Allow running qemu in background

This commit is contained in:
Manuel Thalmann 2024-05-01 00:50:02 +02:00
parent 467b2036a7
commit 539d770d20

View file

@ -5,6 +5,11 @@
type = lib.types.bool;
default = false;
};
qemu.runInBackground = lib.mkOption {
type = lib.types.bool;
default = false;
};
};
};
@ -46,11 +51,22 @@
vm
else
let
prefix = lib.concatStringsSep " " (lib.optional config.virtualisation.runAsRoot "sudo");
prefix =
lib.concatStringsSep " " (
lib.optionals config.virtualisation.runAsRoot (
["sudo"] ++
lib.optional config.virtualisation.qemu.runInBackground "-b"));
suffix =
lib.concatStringsSep " " (
lib.optional
(!config.virtualisation.runAsRoot && config.virtualisation.qemu.runInBackground)
"&");
wrapped = pkgs.writeShellApplication {
name = "run-${config.system.name}-vm";
text = ''
${prefix} ${vm}/bin/run-${config.system.name}-vm
${prefix} ${vm}/bin/run-${config.system.name}-vm ${suffix}
'';
};
in