From d7b8a4e44601121e0773f2aed2406fc231cc8f59 Mon Sep 17 00:00:00 2001 From: Hraban Luyat Date: Mon, 3 Apr 2023 04:44:03 +0100 Subject: [PATCH 1/2] UTM: fix meta.mainProgram field Fixes `nix run nixpkgs#utm` --- pkgs/os-specific/darwin/utm/default.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkgs/os-specific/darwin/utm/default.nix b/pkgs/os-specific/darwin/utm/default.nix index 2e21945288e4..6428b60033f1 100644 --- a/pkgs/os-specific/darwin/utm/default.nix +++ b/pkgs/os-specific/darwin/utm/default.nix @@ -16,8 +16,11 @@ stdenvNoCC.mkDerivation rec { nativeBuildInputs = [ undmg ]; sourceRoot = "."; + # Create bin/ directory just so we can escape it from the mainProgram. nix run + # xxx hard-codes /bin/ as a prefix to the binary path, so going to a parent + # using .. requires the /bin/ directory to exist, even if empty. installPhase = '' - mkdir -p $out/Applications + mkdir -p $out/Applications $out/bin cp -r *.app $out/Applications ''; @@ -46,7 +49,7 @@ stdenvNoCC.mkDerivation rec { ''; homepage = "https://mac.getutm.app/"; changelog = "https://github.com/utmapp/${pname}/releases/tag/v${version}"; - mainProgram = "UTM"; + mainProgram = "../Applications/UTM.app/Contents/MacOS/UTM"; license = licenses.apsl20; platforms = platforms.darwin; # 11.3 is the minimum supported version as of UTM 4. sourceProvenance = with sourceTypes; [ binaryNativeCode ]; From 2c65676e876ef3cd1f3faab225b6f6916f73323b Mon Sep 17 00:00:00 2001 From: Hraban Luyat Date: Mon, 3 Apr 2023 12:48:37 -0400 Subject: [PATCH 2/2] UTM: use makeWrapper to link UTM into bin/ Suggested by github user rrbutani in https://github.com/NixOS/nixpkgs/pull/224435#pullrequestreview-1368309746 --- pkgs/os-specific/darwin/utm/default.nix | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/pkgs/os-specific/darwin/utm/default.nix b/pkgs/os-specific/darwin/utm/default.nix index 6428b60033f1..c88005f09f29 100644 --- a/pkgs/os-specific/darwin/utm/default.nix +++ b/pkgs/os-specific/darwin/utm/default.nix @@ -1,5 +1,6 @@ { lib , undmg +, makeWrapper , fetchurl , stdenvNoCC }: @@ -13,15 +14,23 @@ stdenvNoCC.mkDerivation rec { hash = "sha256-YOmTf50UUvvh4noWnmV6WsoWSua0tpWTgLTg+Cdr3bQ="; }; - nativeBuildInputs = [ undmg ]; + nativeBuildInputs = [ undmg makeWrapper ]; sourceRoot = "."; - # Create bin/ directory just so we can escape it from the mainProgram. nix run - # xxx hard-codes /bin/ as a prefix to the binary path, so going to a parent - # using .. requires the /bin/ directory to exist, even if empty. installPhase = '' - mkdir -p $out/Applications $out/bin + runHook preInstall + + mkdir -p $out/Applications cp -r *.app $out/Applications + + mkdir -p $out/bin + for bin in $out/Applications/UTM.app/Contents/MacOS/*; do + # Symlinking `UTM` doesn't work; seems to look for files in the wrong + # place + makeWrapper $bin "$out/bin/$(basename $bin)" + done + + runHook postInstall ''; meta = with lib; { @@ -49,7 +58,7 @@ stdenvNoCC.mkDerivation rec { ''; homepage = "https://mac.getutm.app/"; changelog = "https://github.com/utmapp/${pname}/releases/tag/v${version}"; - mainProgram = "../Applications/UTM.app/Contents/MacOS/UTM"; + mainProgram = "UTM"; license = licenses.apsl20; platforms = platforms.darwin; # 11.3 is the minimum supported version as of UTM 4. sourceProvenance = with sourceTypes; [ binaryNativeCode ];