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 2 , glib, gtk3, gettext, libxkbfile, libX11, python3 3 , freerdp, libssh, libgcrypt, gnutls, vte 4 , pcre2, libdbusmenu-gtk3, libappindicator-gtk3 ··· 23 sha256 = "sha256-oEgpav4oQ9Sld9PY4TsutS5xEnhQgOHnpQhDesRFTeQ="; 24 }; 25 26 - nativeBuildInputs = [ cmake ninja pkg-config wrapGAppsHook ]; 27 28 buildInputs = [ 29 gsettings-desktop-schemas
··· 1 + { lib, stdenv, fetchFromGitLab, fetchpatch, cmake, ninja, pkg-config, wrapGAppsHook 2 + , desktopToDarwinBundle 3 , glib, gtk3, gettext, libxkbfile, libX11, python3 4 , freerdp, libssh, libgcrypt, gnutls, vte 5 , pcre2, libdbusmenu-gtk3, libappindicator-gtk3 ··· 24 sha256 = "sha256-oEgpav4oQ9Sld9PY4TsutS5xEnhQgOHnpQhDesRFTeQ="; 25 }; 26 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 ]; 37 38 buildInputs = [ 39 gsettings-desktop-schemas
+19 -11
pkgs/build-support/make-darwin-bundle/write-darwin-bundle.nix
··· 1 - { writeScriptBin, lib, ... }: 2 3 let 4 pListText = lib.generators.toPlist { } { ··· 17 18 readonly prefix=$1 19 readonly name=$2 20 - readonly exec=$3 21 readonly icon=$4.icns 22 readonly squircle=''${5:-1} 23 readonly plist=$prefix/Applications/$name.app/Contents/Info.plist 24 25 cat > "$plist" <<EOF 26 ${pListText} 27 EOF 28 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 37 38 - chmod +x "$prefix/Applications/$name.app/Contents/MacOS/$name" 39 ''
··· 1 + { writeScriptBin, lib, makeBinaryWrapper }: 2 3 let 4 pListText = lib.generators.toPlist { } { ··· 17 18 readonly prefix=$1 19 readonly name=$2 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 23 readonly icon=$4.icns 24 readonly squircle=''${5:-1} 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 28 29 cat > "$plist" <<EOF 30 ${pListText} 31 EOF 32 33 + if [[ $squircle == 0 || $squircle == "false" ]]; then 34 + sed '/CFBundleIconFiles/,\|</array>|d' -i "$plist" 35 + fi 36 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 47 ''
+2 -2
pkgs/build-support/setup-hooks/desktop-to-darwin-bundle.sh
··· 204 local -r execNoKC="${execNoK/\%c/$(getDesktopParam "${file}" "Name")}" 205 local -r icon=$(getDesktopParam "${file}" "Icon") 206 local -r execNoKCI="${execNoKC/\%i/${icon:+--icon }${icon}}" 207 - local -r execNoKCIfu="${execNoKCI/\%[fu]/\$1}" 208 - local -r exec="${execNoKCIfu/\%[FU]/\$@}" 209 if [[ "$exec" != "$execRaw" ]]; then 210 echo 1>&2 "desktopToDarwinBundle: Application bundles do not understand desktop entry field codes. Changed '$execRaw' to '$exec'." 211 fi
··· 204 local -r execNoKC="${execNoK/\%c/$(getDesktopParam "${file}" "Name")}" 205 local -r icon=$(getDesktopParam "${file}" "Icon") 206 local -r execNoKCI="${execNoKC/\%i/${icon:+--icon }${icon}}" 207 + local -r execNoKCIfu="${execNoKCI/ \%[fu]/}" 208 + local -r exec="${execNoKCIfu/ \%[FU]/}" 209 if [[ "$exec" != "$execRaw" ]]; then 210 echo 1>&2 "desktopToDarwinBundle: Application bundles do not understand desktop entry field codes. Changed '$execRaw' to '$exec'." 211 fi