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