diff --git a/doc/languages-frameworks/gnome.section.md b/doc/languages-frameworks/gnome.section.md index ecfda62b5700..7e9130218ca6 100644 --- a/doc/languages-frameworks/gnome.section.md +++ b/doc/languages-frameworks/gnome.section.md @@ -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`. diff --git a/pkgs/build-support/setup-hooks/wrap-gapps-hook/wrap-gapps-hook.sh b/pkgs/build-support/setup-hooks/wrap-gapps-hook/wrap-gapps-hook.sh index 92b7a5eee3e7..ef2c02dff02e 100644 --- a/pkgs/build-support/setup-hooks/wrap-gapps-hook/wrap-gapps-hook.sh +++ b/pkgs/build-support/setup-hooks/wrap-gapps-hook/wrap-gapps-hook.sh @@ -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