diff --git a/lib/config/custom-build-vm.nix b/lib/config/custom-build-vm.nix index 9acddbf..91ad630 100644 --- a/lib/config/custom-build-vm.nix +++ b/lib/config/custom-build-vm.nix @@ -16,37 +16,6 @@ let (item: { inherit (item) file value; })); vanillaVM = mergedSystemOption.mergedValue.vm; - - createVMWrapper = - vm: - if (vm.name == packageName) - then - vm - else - let - 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 ${suffix} - ''; - }; - in - pkgs.symlinkJoin { - name = packageName; - paths = [ wrapped ]; - }; in { options = let @@ -106,7 +75,38 @@ in { # Replace native `qemu` with `remote-viewer` system.build = { - vm = lib.mkForce (createVMWrapper vanillaVM); + vm = lib.mkForce ( + ( + vm: + if (vm.name == packageName) + then + vm + else + let + 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 ${suffix} + ''; + }; + in + pkgs.symlinkJoin { + name = packageName; + paths = [ wrapped ]; + }) + vanillaVM); }; }; }