Allow running the VM as root

This commit is contained in:
Manuel Thalmann 2024-05-01 00:27:07 +02:00
parent 0480f0d4a4
commit cf051abbdf

View file

@ -1,11 +1,10 @@
{ config, lib, options, pkgs, ... }: { config, lib, options, pkgs, ... }: {
let
vmOptions = { };
in {
options = { options = {
virtualisation = { virtualisation = {
vmVariant = vmOptions; runAsRoot = lib.mkOption {
vmVariantWithBootLoader = vmOptions; type = lib.types.bool;
default = false;
};
}; };
}; };
@ -36,10 +35,11 @@
mergedSystem.mergedValue.vm mergedSystem.mergedValue.vm
else else
let let
prefix = lib.concatStringsSep " " (lib.optional config.virtualisation.runAsRoot "sudo");
wrapped = pkgs.writeShellApplication { wrapped = pkgs.writeShellApplication {
name = "run-${config.system.name}-vm"; name = "run-${config.system.name}-vm";
text = '' text = ''
${mergedSystem.mergedValue.vm}/bin/run-${config.system.name}-vm ${prefix} ${mergedSystem.mergedValue.vm}/bin/run-${config.system.name}-vm
''; '';
}; };
in in
@ -50,4 +50,4 @@
}); });
}; };
}; };
} }