wrapGAppsHook: only wrap $outBin by default

This commit is contained in:
Stefan Frijters 2026-06-09 10:05:48 +02:00
commit e858e80fb1
No known key found for this signature in database
GPG key ID: 7619A6BC6E7DFA6F
2 changed files with 20 additions and 1 deletions

View file

@ -105,7 +105,7 @@ Given the requirements above, the package expression would become messy quickly:
}
```
Fortunately, we have a [family of hooks]{#ssec-gnome-hooks-wrapgappshook} that automate this. They work in conjunction with other setup hooks that populate environment variables, and will then wrap all executables in `bin` and `libexec` directories using said variables.
Fortunately, we have a [family of hooks]{#ssec-gnome-hooks-wrapgappshook} that automate this. They work in conjunction with other setup hooks that populate environment variables, and will then wrap all executables in `bin` and `libexec` directories using said variables. If a package has multiple outputs, these hooks will work on `outputBin` by default, or on the outputs listed in `wrapGAppsInOutputs` if set.
- [`wrapGAppsHook3`]{#ssec-gnome-hooks-wrapgappshook3} for GTK 3 apps. For convenience, it also adds `dconf.lib` for a GIO module implementing a GSettings backend using `dconf`, `gtk3` for GSettings schemas, and `librsvg` for GdkPixbuf loader to the closure.
- [`wrapGAppsHook4`]{#ssec-gnome-hooks-wrapgappshook4} for GTK 4 apps. Same as `wrapGAppsHook3` but replaces `gtk3` with `gtk4`.

View file

@ -42,13 +42,32 @@ wrapGApp() {
wrapProgram "$program" "${gappsWrapperArgs[@]}" "$@"
}
_wrapGAppsHookMayRunForOutput() {
local -r output="$1"
if [[ -v wrapGAppsInOutputs ]]; then
local allowedOutput
# Support both structuredAttrs on and off
local -a allowedOutputs
concatTo allowedOutputs wrapGAppsInOutputs
for allowedOutput in "${allowedOutputs[@]}"; do
[ "$allowedOutput" = "$output" ] && return 0
done
else
[ "$outputBin" = "$output" ] && return 0
fi
return 1
}
declare -gA wrapGAppsHookHasRunForOutput
# Note: $gappsWrapperArgs still gets defined even if ${dontWrapGApps-} is set.
# $output is brought into scope via fixupPhase() in pkgs/stdenv/generic/setup.sh
wrapGAppsHook() {
# guard against running multiple times for the same output (e.g. due to propagation)
[ "${wrapGAppsHookHasRunForOutput["$output"]:-}" = 1 ] && return 0
wrapGAppsHookHasRunForOutput["$output"]=1
# guard against running for outputs we don't want to run it for
_wrapGAppsHookMayRunForOutput "$output" || return 0
if [[ -z "${dontWrapGApps:-}" ]]; then
local targetDirsThatExist targetDirsRealPath targetDirs targetDir