cargo-tauri: only install .app bundles on Darwin (#499908)

This commit is contained in:
Yt
2026-03-17 05:19:35 +00:00
committed by GitHub
2 changed files with 42 additions and 2 deletions
+12 -2
View File
@@ -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 = ''
+30
View File
@@ -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;