From 3fa41bb91959d9b85d1e543d4b06be764ff35e1d Mon Sep 17 00:00:00 2001 From: Thomas Tuegel Date: Sun, 30 Aug 2015 10:41:43 -0500 Subject: [PATCH 1/2] makeWrapper: accept `--argv0` flag By default `makeWrapper` will not set argv[0] (this is a reversion to the old default behavior). Based on the breakage we have seen from changing the default, this is what most people want. The `wrapProgram` function will send `--argv0 '"$0"'` to `makeWrapper`, i.e. it will continue to pass-through the argv[0] that the wrapper is called with. --- pkgs/build-support/setup-hooks/make-wrapper.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pkgs/build-support/setup-hooks/make-wrapper.sh b/pkgs/build-support/setup-hooks/make-wrapper.sh index f474ff5e88ed5..5150b4f0218ac 100644 --- a/pkgs/build-support/setup-hooks/make-wrapper.sh +++ b/pkgs/build-support/setup-hooks/make-wrapper.sh @@ -2,7 +2,7 @@ makeWrapper() { local original=$1 local wrapper=$2 local params varName value command separator n fileNames - local flagsBefore flags + local argv0 flagsBefore flags mkdir -p "$(dirname $wrapper)" @@ -68,11 +68,17 @@ makeWrapper() { n=$((n + 1)) flagsBefore="$flagsBefore $flags" fi + + if test "$p" = "--argv0"; then + argv0=${params[$((n + 1))]} + n=$((n + 1)) + fi done # Note: extraFlagsArray is an array containing additional flags # that may be set by --run actions. - echo exec -a '"$0"' "$original" $flagsBefore '"${extraFlagsArray[@]}"' '"$@"' >> $wrapper + echo exec ${argv0:+-a $argv0} "$original" \ + $flagsBefore '"${extraFlagsArray[@]}"' '"$@"' >> $wrapper chmod +x $wrapper } @@ -98,5 +104,5 @@ wrapProgram() { local prog="$1" local hidden="$(dirname "$prog")/.$(basename "$prog")"-wrapped mv $prog $hidden - makeWrapper $hidden $prog "$@" + makeWrapper $hidden $prog --argv0 '"$0"' "$@" } From 6d01158bab6b878322db7b04d06aa50afd3aa74f Mon Sep 17 00:00:00 2001 From: Thomas Tuegel Date: Mon, 31 Aug 2015 06:14:09 -0500 Subject: [PATCH 2/2] firefox: set argv[0] explicitly in wrapper Not strictly necessary, but Firefox must be called with exactly this argv[0] every time, so there is no reason to admit any other option. --- pkgs/applications/networking/browsers/firefox/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/applications/networking/browsers/firefox/default.nix b/pkgs/applications/networking/browsers/firefox/default.nix index ff206c50f34ae..5d4d71321ef60 100644 --- a/pkgs/applications/networking/browsers/firefox/default.nix +++ b/pkgs/applications/networking/browsers/firefox/default.nix @@ -99,6 +99,7 @@ stdenv.mkDerivation rec { '' + lib.optionalString enableGTK3 '' wrapProgram "$out/bin/firefox" \ + --argv0 "$out/bin/firefox" \ # argv[0] must point to firefox itself --prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH:" \ --suffix XDG_DATA_DIRS : "$XDG_ICON_DIRS" '';