Merge pull request #249268 from Enzime/remmina-bundle

writeDarwinBundle: use binary wrapper

authored by

toonn and committed by
GitHub
924efe53 67f7fb56

+33 -15
+12 -2
pkgs/applications/networking/remote/remmina/default.nix
··· 1 - { lib, stdenv, fetchFromGitLab, cmake, ninja, pkg-config, wrapGAppsHook 1 + { lib, stdenv, fetchFromGitLab, fetchpatch, cmake, ninja, pkg-config, wrapGAppsHook 2 + , desktopToDarwinBundle 2 3 , glib, gtk3, gettext, libxkbfile, libX11, python3 3 4 , freerdp, libssh, libgcrypt, gnutls, vte 4 5 , pcre2, libdbusmenu-gtk3, libappindicator-gtk3 ··· 23 24 sha256 = "sha256-oEgpav4oQ9Sld9PY4TsutS5xEnhQgOHnpQhDesRFTeQ="; 24 25 }; 25 26 26 - nativeBuildInputs = [ cmake ninja pkg-config wrapGAppsHook ]; 27 + patches = [ 28 + # https://gitlab.com/Remmina/Remmina/-/merge_requests/2525 29 + (fetchpatch { 30 + url = "https://gitlab.com/Remmina/Remmina/-/commit/2ce153411597035d0f3db5177d703541e09eaa06.patch"; 31 + hash = "sha256-RV/8Ze9aN4dW49Z+y3z0jFs4dyEWu7DK2FABtmse9Hc="; 32 + }) 33 + ]; 34 + 35 + nativeBuildInputs = [ cmake ninja pkg-config wrapGAppsHook ] 36 + ++ lib.optionals stdenv.isDarwin [ desktopToDarwinBundle ]; 27 37 28 38 buildInputs = [ 29 39 gsettings-desktop-schemas
+19 -11
pkgs/build-support/make-darwin-bundle/write-darwin-bundle.nix
··· 1 - { writeScriptBin, lib, ... }: 1 + { writeScriptBin, lib, makeBinaryWrapper }: 2 2 3 3 let 4 4 pListText = lib.generators.toPlist { } { ··· 17 17 18 18 readonly prefix=$1 19 19 readonly name=$2 20 - readonly exec=$3 20 + # TODO: support executables with spaces in their names 21 + readonly execName=''${3%% *} # Before the first space 22 + [[ $3 =~ " " ]] && readonly execArgs=''${3#* } # Everything after the first space 21 23 readonly icon=$4.icns 22 24 readonly squircle=''${5:-1} 23 25 readonly plist=$prefix/Applications/$name.app/Contents/Info.plist 26 + readonly binary=$prefix/bin/$execName 27 + readonly bundleExecutable=$prefix/Applications/$name.app/Contents/MacOS/$name 24 28 25 29 cat > "$plist" <<EOF 26 30 ${pListText} 27 31 EOF 28 32 29 - if [[ $squircle == 0 || $squircle == "false" ]]; then 30 - sed '/CFBundleIconFiles/,\|</array>|d' -i "$plist" 31 - fi 32 - 33 - cat > "$prefix/Applications/$name.app/Contents/MacOS/$name" <<EOF 34 - #!/bin/bash 35 - exec $prefix/bin/$exec 36 - EOF 33 + if [[ $squircle == 0 || $squircle == "false" ]]; then 34 + sed '/CFBundleIconFiles/,\|</array>|d' -i "$plist" 35 + fi 37 36 38 - chmod +x "$prefix/Applications/$name.app/Contents/MacOS/$name" 37 + if [[ -n "$execArgs" ]]; then 38 + ( 39 + source ${makeBinaryWrapper}/nix-support/setup-hook 40 + # WORKAROUND: makeBinaryWrapper fails when -u is set 41 + set +u 42 + makeBinaryWrapper "$binary" "$bundleExecutable" --add-flags "$execArgs" 43 + ) 44 + else 45 + ln -s "$binary" "$bundleExecutable" 46 + fi 39 47 ''
+2 -2
pkgs/build-support/setup-hooks/desktop-to-darwin-bundle.sh
··· 204 204 local -r execNoKC="${execNoK/\%c/$(getDesktopParam "${file}" "Name")}" 205 205 local -r icon=$(getDesktopParam "${file}" "Icon") 206 206 local -r execNoKCI="${execNoKC/\%i/${icon:+--icon }${icon}}" 207 - local -r execNoKCIfu="${execNoKCI/\%[fu]/\$1}" 208 - local -r exec="${execNoKCIfu/\%[FU]/\$@}" 207 + local -r execNoKCIfu="${execNoKCI/ \%[fu]/}" 208 + local -r exec="${execNoKCIfu/ \%[FU]/}" 209 209 if [[ "$exec" != "$execRaw" ]]; then 210 210 echo 1>&2 "desktopToDarwinBundle: Application bundles do not understand desktop entry field codes. Changed '$execRaw' to '$exec'." 211 211 fi