treewide: inject xdg-open into wrappers as $PATH suffix

The xdg-open utility is only ever a runtime dependency and its
dependents only expect that it accept a URI as a command line
argument and do something with it that the user would expect.
For such as a trivial relationship it should be possible for
users to override xdg-open with something else in their PATH.
This commit is contained in:
Emery Hemingway 2022-07-11 18:23:52 -05:00 committed by ehmry
parent 1a9c66f883
commit b5526585c2
32 changed files with 72 additions and 45 deletions

View file

@ -27,10 +27,6 @@ stdenv.mkDerivation rec {
libxkbfile pixman xcbutil xcbutilwm zlib
];
binPath = lib.makeBinPath [
xdg-utils zenity ffmpeg
];
installPhase = ''
mkdir -p $out
cp -r opt/bitwig-studio $out/libexec
@ -77,7 +73,8 @@ stdenv.mkDerivation rec {
-not -path '*/resources/*' | \
while IFS= read -r f ; do
wrapProgram $f \
--prefix PATH : "${binPath}" \
--suffix PATH : "${lib.makeBinPath [ ffmpeg zenity ]}" \
--prefix PATH : "${lib.makeBinPath [ xdg-utils ]}" \
"''${gappsWrapperArgs[@]}" \
--set LD_PRELOAD "${libxkbcommon.out}/lib/libxkbcommon.so" || true
done

View file

@ -27,10 +27,6 @@ stdenv.mkDerivation rec {
alsa-lib cairo freetype gdk-pixbuf glib gtk3 libxcb xcbutil xcbutilwm zlib libXtst libxkbcommon pulseaudio libjack2 libX11 libglvnd libXcursor stdenv.cc.cc.lib
];
binPath = lib.makeBinPath [
xdg-utils ffmpeg
];
ldLibraryPath = lib.strings.makeLibraryPath buildInputs;
installPhase = ''
@ -60,8 +56,9 @@ stdenv.mkDerivation rec {
patchelf --set-interpreter "${stdenv.cc.bintools.dynamicLinker}" $f
wrapProgram $f \
"''${gappsWrapperArgs[@]}" \
--prefix PATH : "${binPath}" \
--suffix LD_LIBRARY_PATH : "${ldLibraryPath}"
--prefix LD_LIBRARY_PATH : "${ldLibraryPath}" \
--prefix PATH : "${lib.makeBinPath [ ffmpeg ]}" \
--suffix PATH : "${lib.makeBinPath [ xdg-utils ]}"
done
'';

View file

@ -53,9 +53,11 @@ stdenv.mkDerivation rec {
-not -path '*/resources/*' | \
while IFS= read -r f ; do
patchelf --set-interpreter "${stdenv.cc.bintools.dynamicLinker}" $f
# make xdg-open overrideable at runtime
wrapProgram $f \
"''${gappsWrapperArgs[@]}" \
--prefix PATH : "${lib.makeBinPath [ xdg-utils ffmpeg ]}" \
--prefix PATH : "${lib.makeBinPath [ ffmpeg ]}" \
--suffix PATH : "${lib.makeBinPath [ xdg-utils ]}" \
--suffix LD_LIBRARY_PATH : "${lib.strings.makeLibraryPath buildInputs}"
done

View file

@ -44,11 +44,12 @@ stdenvNoCC.mkDerivation rec {
install -Dm755 irpf.jar "$BASEDIR/${pname}.jar"
install -Dm644 Leia-me.htm offline.png online.png pgd-updater.jar "$BASEDIR"
# make xdg-open overrideable at runtime
makeWrapper ${jdk11}/bin/java $out/bin/${pname} \
--add-flags "-Dawt.useSystemAAFontSettings=on" \
--add-flags "-Dswing.aatext=true" \
--add-flags "-jar $BASEDIR/${pname}.jar" \
--prefix PATH : ${lib.makeBinPath [ xdg-utils ]} \
--suffix PATH : ${lib.makeBinPath [ xdg-utils ]} \
--set _JAVA_AWT_WM_NONREPARENTING 1 \
--set AWT_TOOLKIT MToolkit

View file

@ -94,9 +94,11 @@ stdenv.mkDerivation rec {
'';
preFixup = ''
# make xdg-open overrideable at runtime
gappsWrapperArgs+=(
--set PERL5LIB ${perlPackages.makePerlPath perlModules} \
--prefix PATH : ${lib.makeBinPath [ imagemagick xdg-utils ] }
--prefix PATH : ${lib.makeBinPath [ imagemagick ] }
--suffix PATH : ${lib.makeBinPath [ xdg-utils ] }
)
'';

View file

@ -126,8 +126,9 @@ in stdenv.mkDerivation rec {
# Electron is trying to open udev via dlopen()
# and for some reason that doesn't seem to be impacted from the rpath.
# Adding udev to LD_LIBRARY_PATH fixes that.
# Make xdg-open overrideable at runtime.
makeWrapper $out/share/1password/1password $out/bin/1password \
--prefix PATH : ${lib.makeBinPath [ xdg-utils ]} \
--suffix PATH : ${lib.makeBinPath [ xdg-utils ]} \
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ udev ]}
runHook postInstall

View file

@ -126,8 +126,9 @@ in stdenv.mkDerivation rec {
# Electron is trying to open udev via dlopen()
# and for some reason that doesn't seem to be impacted from the rpath.
# Adding udev to LD_LIBRARY_PATH fixes that.
# Make xdg-open overrideable at runtime.
makeWrapper $out/share/1password/1password $out/bin/1password \
--prefix PATH : ${lib.makeBinPath [ xdg-utils ]} \
--suffix PATH : ${lib.makeBinPath [ xdg-utils ]} \
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ udev ]}
runHook postInstall

View file

@ -25,7 +25,7 @@ stdenv.mkDerivation {
export LD_LIBRARY_PATH="${lib.makeLibraryPath [gtk2 mono]}"
# We need PATH from user env for xdg-open to find its tools, which
# typically depend on the currently running desktop environment.
export PATH="${lib.makeBinPath [ avrdude xdg-utils ]}:\$PATH"
export PATH="\$PATH:${lib.makeBinPath [ avrdude xdg-utils ]}"
# avrdudess must have its resource files in its current working directory
cd $out/avrdudess && exec ${mono}/bin/mono "$out/avrdudess/avrdudess.exe" "\$@"

View file

@ -61,12 +61,13 @@ stdenv.mkDerivation rec {
PYTHON = withPython;
};
runtimeDeps = [ unzip zip p7zip xz gzip bzip2 gnutar xdg-utils ];
runtimeDeps = [ unzip zip p7zip xz gzip bzip2 gnutar ];
postInstall = ''
wrapProgram $out/bin/far2l \
--argv0 $out/bin/far2l \
--prefix PATH : ${lib.makeBinPath runtimeDeps}
--prefix PATH : ${lib.makeBinPath runtimeDeps} \
--suffix PATH : ${lib.makeBinPath [ xdg-utils ]}
'';
meta = with lib; {

View file

@ -33,8 +33,9 @@ buildGoModule rec {
'';
preFixup = ''
# make xdg-open overrideable at runtime
gappsWrapperArgs+=(
--prefix PATH : ${xdg-utils}/bin
--suffix PATH : ${xdg-utils}/bin
--prefix XDG_DATA_DIRS : $out/share
)
'';

View file

@ -141,8 +141,9 @@ stdenv.mkDerivation rec {
--prefix PATH : ${makeBinPath [ iproute2 networkmanager dnsmasq ]} \
--set LD_LIBRARY_PATH $out/opt/appgate/service
# make xdg-open overrideable at runtime
makeWrapper $out/opt/appgate/Appgate $out/bin/appgate \
--prefix PATH : ${makeBinPath [ xdg-utils ]} \
--suffix PATH : ${makeBinPath [ xdg-utils ]} \
--set LD_LIBRARY_PATH $out/opt/appgate:${makeLibraryPath deps}
wrapProgram $out/opt/appgate/linux/set_dns --set PYTHONPATH $PYTHONPATH

View file

@ -73,7 +73,7 @@ let
libxkbcommon libXScrnSaver libXcomposite libXcursor libXdamage
libXext libXfixes libXi libXrandr libXrender libxshmfence
libXtst libuuid mesa nspr nss pango pipewire udev wayland
xdg-utils xorg.libxcb zlib snappy
xorg.libxcb zlib snappy
]
++ optional pulseSupport libpulseaudio
++ optional libvaSupport libva;
@ -170,6 +170,7 @@ stdenv.mkDerivation rec {
gappsWrapperArgs+=(
--prefix LD_LIBRARY_PATH : ${rpath}
--prefix PATH : ${binpath}
--suffix PATH : ${lib.makeBinPath [ xdg-utils ]}
${optionalString (enableFeatures != []) ''
--add-flags "--enable-features=${strings.concatStringsSep "," enableFeatures}"
''}

View file

@ -271,11 +271,12 @@ let
mv "$executablePath" "$oldExe"
fi
# make xdg-open overrideable at runtime
makeWrapper "$oldExe" \
"''${executablePath}${nameSuffix}" \
--prefix LD_LIBRARY_PATH ':' "$libs" \
--suffix-each GTK_PATH ':' "$gtk_modules" \
--prefix PATH ':' "${xdg-utils}/bin" \
--suffix PATH ':' "${xdg-utils}/bin" \
--suffix PATH ':' "$out/bin" \
--set MOZ_APP_LAUNCHER "${launcherName}" \
--set MOZ_SYSTEM_DIR "$out/lib/mozilla" \

View file

@ -63,7 +63,7 @@ let
dbus gdk-pixbuf gcc-unwrapped.lib
systemd
libexif pciutils
liberation_ttf curl util-linux xdg-utils wget
liberation_ttf curl util-linux wget
flac harfbuzz icu libpng opusWithCustomModes snappy speechd
bzip2 libcap at-spi2-atk at-spi2-core
libkrb5 libdrm libglvnd mesa coreutils
@ -145,6 +145,7 @@ in stdenv.mkDerivation {
makeWrapper "$out/share/google/$appname/google-$appname" "$exe" \
--prefix LD_LIBRARY_PATH : "$rpath" \
--prefix PATH : "$binpath" \
--suffix PATH : "${lib.makeBinPath [ xdg-utils ]}" \
--prefix XDG_DATA_DIRS : "$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH:${addOpenGLRunpath.driverLink}/share" \
--set CHROME_WRAPPER "google-chrome-$dist" \
--add-flags ${escapeShellArg commandLineArgs} \

View file

@ -108,7 +108,7 @@ stdenv.mkDerivation rec {
# Wrap the startup command
makeWrapper $out/opt/ArmCord/armcord $out/bin/armcord \
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath buildInputs}" \
--prefix PATH : ${lib.makeBinPath [ xdg-utils ]} \
--suffix PATH : ${lib.makeBinPath [ xdg-utils ]} \
"''${gappsWrapperArgs[@]}"
# Fix desktop link

View file

@ -111,10 +111,11 @@ stdenv.mkDerivation rec {
cc $localtime64_stub -shared -o "${placeholder "out"}"/opt/BlueJeans/liblocaltime64_stub.so
# make xdg-open overrideable at runtime
makeWrapper $out/opt/BlueJeans/bluejeans-v2 $out/bin/bluejeans \
--set LD_LIBRARY_PATH "${libPath}":"${placeholder "out"}"/opt/BlueJeans \
--set LD_PRELOAD "$out"/opt/BlueJeans/liblocaltime64_stub.so \
--prefix PATH : ${lib.makeBinPath [ xdg-utils ]}
--suffix PATH : ${lib.makeBinPath [ xdg-utils ]}
substituteInPlace "$out"/share/applications/bluejeans-v2.desktop \
--replace "/opt/BlueJeans/bluejeans-v2" "$out/bin/bluejeans"

View file

@ -85,9 +85,10 @@ stdenv.mkDerivation rec {
dontWrapGApps = true;
postFixup = ''
# make xdg-open overrideable at runtime
wrapProgram $out/opt/${name}/${pname} \
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath runtimeDependencies}" \
--prefix PATH : ${xdg-utils}/bin \
--suffix PATH : ${xdg-utils}/bin \
"''${gappsWrapperArgs[@]}"
'';
}

View file

@ -164,11 +164,12 @@ let
patchelf --set-rpath ${rpath}:$out/lib/slack $file || true
done
# Replace the broken bin/slack symlink with a startup wrapper
# Replace the broken bin/slack symlink with a startup wrapper.
# Make xdg-open overrideable at runtime.
rm $out/bin/slack
makeWrapper $out/lib/slack/slack $out/bin/slack \
--prefix XDG_DATA_DIRS : $GSETTINGS_SCHEMAS_PATH \
--prefix PATH : ${lib.makeBinPath [xdg-utils]} \
--suffix PATH : ${lib.makeBinPath [xdg-utils]} \
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--enable-features=UseOzonePlatform --ozone-platform=wayland}}"
# Fix the desktop link

View file

@ -173,7 +173,7 @@ env.mkDerivation rec {
wrapProgram $out/bin/telegram-desktop \
"''${gappsWrapperArgs[@]}" \
"''${qtWrapperArgs[@]}" \
--prefix PATH : ${lib.makeBinPath [ xdg-utils]} \
--suffix PATH : ${lib.makeBinPath [ xdg-utils]} \
--set XDG_RUNTIME_DIR "XDG-RUNTIME-DIR"
sed -i $out/bin/telegram-desktop \
-e "s,'XDG-RUNTIME-DIR',\"\''${XDG_RUNTIME_DIR:-/run/user/\$(id --user)}\","

View file

@ -53,8 +53,9 @@ in stdenv.mkDerivation {
'';
postFixup = ''
# make xdg-open overrideable at runtime
makeWrapper $out/opt/wavebox/Wavebox $out/bin/wavebox \
--prefix PATH : ${xdg-utils}/bin
--suffix PATH : ${xdg-utils}/bin
'';
meta = with lib; {

View file

@ -79,7 +79,8 @@ mkDerivation rec {
"--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ libsecret ]}"
# See also: https://bugreports.qt.io/browse/QTBUG-85967
"--set QML_DISABLE_DISK_CACHE 1"
"--prefix PATH : ${lib.makeBinPath [ xdg-utils ]}"
# make xdg-open overrideable at runtime
"--suffix PATH : ${lib.makeBinPath [ xdg-utils ]}"
];
cmakeFlags = [

View file

@ -119,7 +119,7 @@ stdenv.mkDerivation rec {
unzip $out/lib/javafx-web-18-linux${lib.optionalString stdenv.isAarch64 "-aarch64"}.jar libjfxwebkit.so -d $out/lib/
wrapProgram $out/bin/JabRef \
--prefix PATH : ${lib.makeBinPath [ xdg-utils ]} \
--suffix PATH : ${lib.makeBinPath [ xdg-utils ]} \
--set JAVA_HOME "${jdk}" \
--set JAVA_OPTS "-Djava.library.path=$out/lib/ --patch-module org.jabref=$out/share/java/jabref/resources/main"

View file

@ -26,8 +26,9 @@ mkDerivation rec {
'';
postFixup = ''
# make xdg-open overrideable at runtime
wrapProgram $out/bin/mytetra \
--prefix PATH : ${xdg-utils}/bin
--suffix PATH : ${xdg-utils}/bin
'';
meta = with lib; {

View file

@ -26,7 +26,8 @@ stdenv.mkDerivation rec {
cp git-open $out/bin
installManPage git-open.1
wrapProgram $out/bin/git-open \
--prefix PATH : "${lib.makeBinPath [ git xdg-utils gnugrep ]}"
--prefix PATH : "${lib.makeBinPath [ git gnugrep ]}" \
--suffix PATH : "${lib.makeBinPath [ xdg-utils ]}"
'';
meta = with lib; {

View file

@ -22,7 +22,10 @@ buildGoModule rec {
ldflags = [ "-s" "-w" "-X main.version=${version}" ];
postInstall = ''
wrapProgram $out/bin/lab --prefix PATH ":" "${lib.makeBinPath [ git xdg-utils ]}";
# make xdg-open overrideable at runtime
wrapProgram $out/bin/lab \
--prefix PATH ":" "${lib.makeBinPath [ git ]}" \
--suffix PATH ":" "${lib.makeBinPath [ xdg-utils ]}"
installShellCompletion --cmd lab \
--bash <($out/bin/lab completion bash) \
--fish <($out/bin/lab completion fish) \

View file

@ -72,8 +72,10 @@ buildPerlModule rec {
wrapProgram "$out/bin/pipe-viewer" \
--prefix PATH : "${lib.makeBinPath [ ffmpeg wget youtube-dl yt-dlp ]}"
'' + lib.optionalString withGtk3 ''
# make xdg-open overrideable at runtime
wrapProgram "$out/bin/gtk-pipe-viewer" ''${gappsWrapperArgs[@]} \
--prefix PATH : "${lib.makeBinPath [ ffmpeg wget xdg-utils youtube-dl yt-dlp ]}"
--prefix PATH : "${lib.makeBinPath [ ffmpeg wget youtube-dl yt-dlp ]}" \
--suffix PATH : "${lib.makeBinPath [ xdg-utils ]}"
'';
meta = with lib; {

View file

@ -31,7 +31,8 @@ stdenv.mkDerivation rec {
postInstall = ''
rm -r $out/include
wrapProgram $out/bin/enigma --prefix PATH : "${lib.makeBinPath [ xdg-utils ]}"
# make xdg-open overrideable at runtime
wrapProgram $out/bin/enigma --suffix PATH : "${lib.makeBinPath [ xdg-utils ]}"
'';
meta = with lib; {

View file

@ -56,7 +56,9 @@ python3Packages.buildPythonApplication rec {
makeWrapperArgs = [
"\${gappsWrapperArgs[@]}"
"--prefix PATH : ${lib.makeBinPath [ xdg-user-dirs xdg-utils wine winetricks pciutils glxinfo ]}"
"--prefix PATH : ${lib.makeBinPath [ xdg-user-dirs wine winetricks pciutils glxinfo ]}"
# make xdg-open overrideable at runtime
"--suffix PATH : ${lib.makeBinPath [ xdg-utils ]}"
];
postPatch = ''

View file

@ -119,8 +119,9 @@ buildGoModule rec {
postInstall = ''
install -Dm755 -t $client/bin $out/bin/tsh
wrapProgram $client/bin/tsh --prefix PATH : ${lib.makeBinPath [ xdg-utils ]}
wrapProgram $out/bin/tsh --prefix PATH : ${lib.makeBinPath [ xdg-utils ]}
# make xdg-open overrideable at runtime
wrapProgram $client/bin/tsh --suffix PATH : ${lib.makeBinPath [ xdg-utils ]}
wrapProgram $out/bin/tsh --suffix PATH : ${lib.makeBinPath [ xdg-utils ]}
'';
doInstallCheck = true;

View file

@ -21,7 +21,7 @@ buildGoModule rec {
postInstall = ''
mv $out/bin/cmd $out/bin/aws-sso
wrapProgram $out/bin/aws-sso \
--prefix PATH : ${lib.makeBinPath [ xdg-utils ]}
--suffix PATH : ${lib.makeBinPath [ xdg-utils ]}
'';
meta = with lib; {

View file

@ -21,7 +21,8 @@ buildGoModule rec {
nativeBuildInputs = [ installShellFiles makeWrapper ];
postInstall = ''
wrapProgram $out/bin/aws-vault --prefix PATH : ${lib.makeBinPath [ xdg-utils ]}
# make xdg-open overrideable at runtime
wrapProgram $out/bin/aws-vault --suffix PATH : ${lib.makeBinPath [ xdg-utils ]}
installShellCompletion --cmd aws-vault \
--bash $src/contrib/completions/bash/aws-vault.bash \
--fish $src/contrib/completions/fish/aws-vault.fish \

View file

@ -5,7 +5,6 @@
let
pythonPackages = python3Packages;
binPath = lib.makeBinPath [ xdg-utils dnsmasq dhcp iproute2 ];
in stdenv.mkDerivation rec {
pname = "blueman";
@ -41,8 +40,12 @@ in stdenv.mkDerivation rec {
(lib.enableFeature withPulseAudio "pulseaudio")
];
makeWrapperArgs = [
"--prefix PATH ':' ${lib.makeBinPath [ dnsmasq dhcp iproute2 ]}"
"--suffix PATH ':' ${lib.makeBinPath [ xdg-utils ]}"
];
postFixup = ''
makeWrapperArgs="--prefix PATH ':' ${binPath}"
# This mimics ../../../development/interpreters/python/wrap.sh
wrapPythonProgramsIn "$out/bin" "$out $pythonPath"
wrapPythonProgramsIn "$out/libexec" "$out $pythonPath"