diff --git a/pkgs/applications/editors/neovim/utils.nix b/pkgs/applications/editors/neovim/utils.nix index e721457f2df0..ee0abb582891 100644 --- a/pkgs/applications/editors/neovim/utils.nix +++ b/pkgs/applications/editors/neovim/utils.nix @@ -108,7 +108,7 @@ let hostprog_check_table); in [ - "--argv0" "$0" "--add-flags" (lib.escapeShellArgs flags) + "--inherit-argv0" "--add-flags" (lib.escapeShellArgs flags) ] ++ lib.optionals withRuby [ "--set" "GEM_HOME" "${rubyEnv}/${rubyEnv.ruby.gemPath}" ] ++ lib.optionals (binPath != "") [ diff --git a/pkgs/applications/networking/browsers/firefox/wrapper.nix b/pkgs/applications/networking/browsers/firefox/wrapper.nix index 1a5556b82bea..3da36e520c37 100644 --- a/pkgs/applications/networking/browsers/firefox/wrapper.nix +++ b/pkgs/applications/networking/browsers/firefox/wrapper.nix @@ -237,10 +237,7 @@ let parseMakeCWrapperCall() { shift # makeCWrapper oldExe=$1; shift - for arg do case $arg in - --inherit-argv0) oldWrapperArgs+=(--argv0 '$0');; # makeWrapper doesn't understand --inherit-argv0 - *) oldWrapperArgs+=("$arg");; - esac done + oldWrapperArgs=("$@") } eval "parseMakeCWrapperCall ''${wrapperCmd//"${browser}"/"$out"}" rm "$executablePath" diff --git a/pkgs/applications/video/mpv/wrapper.nix b/pkgs/applications/video/mpv/wrapper.nix index 28414c3756d9..3dfe83e2449e 100644 --- a/pkgs/applications/video/mpv/wrapper.nix +++ b/pkgs/applications/video/mpv/wrapper.nix @@ -32,7 +32,7 @@ let # All arguments besides the input and output binaries (${mpv}/bin/mpv and # $out/bin/mpv). These are used by the darwin specific makeWrapper call # used to wrap $out/Applications/mpv.app/Contents/MacOS/mpv as well. - mostMakeWrapperArgs = lib.strings.escapeShellArgs ([ "--argv0" "'$0'" + mostMakeWrapperArgs = lib.strings.escapeShellArgs ([ "--inherit-argv0" # These are always needed (TODO: Explain why) "--prefix" "LUA_CPATH" ";" "${mpv.luaEnv}/lib/lua/${mpv.lua.luaversion}/?.so" "--prefix" "LUA_PATH" ";" "${mpv.luaEnv}/share/lua/${mpv.lua.luaversion}/?.lua" @@ -53,7 +53,7 @@ let )) ++ extraMakeWrapperArgs) ; umpvWrapperArgs = lib.strings.escapeShellArgs ([ - "--argv0" "'$0'" + "--inherit-argv0" "--set" "MPV" "${placeholder "out"}/bin/mpv" ] ++ extraUmpvWrapperArgs) ; diff --git a/pkgs/build-support/setup-hooks/make-binary-wrapper/make-binary-wrapper.sh b/pkgs/build-support/setup-hooks/make-binary-wrapper/make-binary-wrapper.sh index 9496c918580a..ff3f1d3f0c7f 100644 --- a/pkgs/build-support/setup-hooks/make-binary-wrapper/make-binary-wrapper.sh +++ b/pkgs/build-support/setup-hooks/make-binary-wrapper/make-binary-wrapper.sh @@ -15,17 +15,17 @@ assertExecutable() { # makeWrapper EXECUTABLE OUT_PATH ARGS # ARGS: -# --argv0 NAME : set name of executed process to NAME -# (otherwise it’s called …-wrapped) +# --argv0 NAME : set the name of the executed process to NAME +# (if unset or empty, defaults to EXECUTABLE) # --inherit-argv0 : the executable inherits argv0 from the wrapper. # (use instead of --argv0 '$0') -# --set VAR VAL : add VAR with value VAL to the executable’s -# environment +# --set VAR VAL : add VAR with value VAL to the executable's environment # --set-default VAR VAL : like --set, but only adds VAR if not already set in # the environment # --unset VAR : remove VAR from the environment # --chdir DIR : change working directory (use instead of --run "cd DIR") # --add-flags FLAGS : add FLAGS to invocation of executable +# TODO(@ncfavier): --append-flags # --prefix ENV SEP VAL : suffix/prefix ENV with VAL, separated by SEP # --suffix @@ -65,8 +65,6 @@ wrapProgramBinary() { hidden="${hidden}_" done mv "$prog" "$hidden" - # Silence warning about unexpanded $0: - # shellcheck disable=SC2016 makeWrapper "$hidden" "$prog" --inherit-argv0 "${@:2}" } diff --git a/pkgs/build-support/setup-hooks/make-wrapper.sh b/pkgs/build-support/setup-hooks/make-wrapper.sh index c6188c2cd96b..8a38c39efc47 100644 --- a/pkgs/build-support/setup-hooks/make-wrapper.sh +++ b/pkgs/build-support/setup-hooks/make-wrapper.sh @@ -11,16 +11,18 @@ assertExecutable() { # makeWrapper EXECUTABLE OUT_PATH ARGS # ARGS: -# --argv0 NAME : set name of executed process to NAME -# (otherwise it’s called …-wrapped) -# --set VAR VAL : add VAR with value VAL to the executable’s -# environment +# --argv0 NAME : set the name of the executed process to NAME +# (if unset or empty, defaults to EXECUTABLE) +# --inherit-argv0 : the executable inherits argv0 from the wrapper. +# (use instead of --argv0 '$0') +# --set VAR VAL : add VAR with value VAL to the executable's environment # --set-default VAR VAL : like --set, but only adds VAR if not already set in # the environment # --unset VAR : remove VAR from the environment # --chdir DIR : change working directory (use instead of --run "cd DIR") # --run COMMAND : run command before the executable # --add-flags FLAGS : add FLAGS to invocation of executable +# TODO(@ncfavier): --append-flags # --prefix ENV SEP VAL : suffix/prefix ENV with VAL, separated by SEP # --suffix @@ -166,6 +168,9 @@ makeShellWrapper() { elif [[ "$p" == "--argv0" ]]; then argv0="${params[$((n + 1))]}" n=$((n + 1)) + elif [[ "$p" == "--inherit-argv0" ]]; then + # Whichever comes last of --argv0 and --inherit-argv0 wins + argv0='$0' else die "makeWrapper doesn't understand the arg $p" fi @@ -206,7 +211,5 @@ wrapProgramShell() { hidden="${hidden}_" done mv "$prog" "$hidden" - # Silence warning about unexpanded $0: - # shellcheck disable=SC2016 - makeWrapper "$hidden" "$prog" --argv0 '$0' "${@:2}" + makeWrapper "$hidden" "$prog" --inherit-argv0 "${@:2}" }