Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

makeWrapper: accept --argv0 flag #9562

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkgs/applications/networking/browsers/firefox/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment ruins the backslash ;-)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And even when I fix it, this wrapper doesn't work for me. It seems like the .firefox-wrapped basename is important, after all.

--prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH:" \
--suffix XDG_DATA_DIRS : "$XDG_ICON_DIRS"
'';
Expand Down
12 changes: 9 additions & 3 deletions pkgs/build-support/setup-hooks/make-wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)"

Expand Down Expand Up @@ -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
}
Expand All @@ -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"' "$@"
}