From 467b2036a70ee2dbe67ad80dddfb11e9dce193f7 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Wed, 1 May 2024 00:43:41 +0200 Subject: [PATCH] Remove redundancies --- lib/config/custom-build-vm.nix | 37 +++++++++++++++++----------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/lib/config/custom-build-vm.nix b/lib/config/custom-build-vm.nix index ec213e1..e75180f 100644 --- a/lib/config/custom-build-vm.nix +++ b/lib/config/custom-build-vm.nix @@ -40,24 +40,25 @@ (item: { inherit (item) file value; })); in lib.mkForce ( - if (mergedSystem.mergedValue.vm.name == packageName) - then - mergedSystem.mergedValue.vm - else - let - prefix = lib.concatStringsSep " " (lib.optional config.virtualisation.runAsRoot "sudo"); - wrapped = pkgs.writeShellApplication { - name = "run-${config.system.name}-vm"; - text = '' - ${prefix} ${mergedSystem.mergedValue.vm}/bin/run-${config.system.name}-vm - ''; - }; - in - # Rename package to `nixos-vm` - pkgs.symlinkJoin { - name = packageName; - paths = [ wrapped ]; - }); + with { inherit (mergedSystem.mergedValue) vm; }; + if (vm.name == packageName) + then + vm + else + let + prefix = lib.concatStringsSep " " (lib.optional config.virtualisation.runAsRoot "sudo"); + wrapped = pkgs.writeShellApplication { + name = "run-${config.system.name}-vm"; + text = '' + ${prefix} ${vm}/bin/run-${config.system.name}-vm + ''; + }; + in + # Rename package to `nixos-vm` + pkgs.symlinkJoin { + name = packageName; + paths = [ wrapped ]; + }); }; }; }