diff --git a/pkgs/by-name/ca/cargo-tauri/hook.nix b/pkgs/by-name/ca/cargo-tauri/hook.nix index 3b2f72f76be6..cb829f9a96a5 100644 --- a/pkgs/by-name/ca/cargo-tauri/hook.nix +++ b/pkgs/by-name/ca/cargo-tauri/hook.nix @@ -48,8 +48,18 @@ makeSetupHook { installScript = { darwin = '' - mkdir -p $out - mv "$targetDir"/bundle/macos $out/Applications + mkdir -p "$out/Applications" + + shopt -s nullglob + appBundles=("$targetDir"/bundle/macos/*.app) + shopt -u nullglob + + if [ "''${#appBundles[@]}" -eq 0 ]; then + echo "cargo-tauri.hook: no .app bundles found in $targetDir/bundle/macos" >&2 + exit 1 + fi + + mv -- "''${appBundles[@]}" "$out/Applications/" ''; linux = '' diff --git a/pkgs/by-name/ca/cargo-tauri/test-app.nix b/pkgs/by-name/ca/cargo-tauri/test-app.nix index 0ba48a2a21ec..0b3193e6548f 100644 --- a/pkgs/by-name/ca/cargo-tauri/test-app.nix +++ b/pkgs/by-name/ca/cargo-tauri/test-app.nix @@ -64,10 +64,40 @@ stdenv.mkDerivation (finalAttrs: { preBuild = '' pnpm --filter '@tauri-apps/api' build ''; + postBuild = lib.optionalString stdenv.hostPlatform.isDarwin '' + bundleDir="target/${stdenv.hostPlatform.rust.cargoShortTarget}/''${cargoBuildType:-release}/bundle/macos" + touch "$bundleDir/.test-hidden-entry" + touch "$bundleDir/test-visible-entry" + ''; # No one should be actually running this, so lets save some time buildType = "debug"; doCheck = false; + doInstallCheck = stdenv.hostPlatform.isDarwin; + installCheckPhase = lib.optionalString stdenv.hostPlatform.isDarwin '' + runHook preInstallCheck + + test -d "$out/Applications" + + shopt -s nullglob dotglob + appBundles=("$out"/Applications/*.app) + nonAppEntries=("$out"/Applications/*) + shopt -u nullglob dotglob + + test "''${#appBundles[@]}" -gt 0 + + for entry in "''${nonAppEntries[@]}"; do + case "$entry" in + *.app) ;; + *) + echo "unexpected non-.app entry in Applications: $entry" >&2 + exit 1 + ;; + esac + done + + runHook postInstallCheck + ''; meta = { inherit (cargo-tauri.hook.meta) platforms;