1 if [[ -z "${__nix_wrapQtAppsHook-}" ]]; then
2 __nix_wrapQtAppsHook
=1 # Don't run this hook more than once.
4 # Inherit arguments given in mkDerivation
5 qtWrapperArgs
=( ${qtWrapperArgs-} )
10 for pkg
in "${qtHostPathSeen[@]}"
12 if [ "${pkg:?}" == "$1" ]
18 qtHostPathSeen
+=("$1")
23 qtUnseenHostPath
"$1" ||
return 0
25 local pluginDir
="$1/${qtPluginPrefix:?}"
26 if [ -d "$pluginDir" ]
28 qtWrapperArgs
+=(--prefix QT_PLUGIN_PATH
: "$pluginDir")
31 local qmlDir
="$1/${qtQmlPrefix:?}"
34 qtWrapperArgs
+=(--prefix QML2_IMPORT_PATH
: "$qmlDir")
37 addEnvHooks
"$hostOffset" qtHostPathHook
43 makeWrapper
"$original" "$wrapper" "${qtWrapperArgs[@]}" "$@"
49 wrapProgram
"$program" "${qtWrapperArgs[@]}" "$@"
53 local xdgDataDir
="${!outputBin}/share"
54 if [ -d "$xdgDataDir" ]
56 qtWrapperArgs
+=(--prefix XDG_DATA_DIRS
: "$xdgDataDir")
59 local xdgConfigDir
="${!outputBin}/etc/xdg"
60 if [ -d "$xdgConfigDir" ]
62 qtWrapperArgs
+=(--prefix XDG_CONFIG_DIRS
: "$xdgConfigDir")
65 qtHostPathHook
"${!outputBin}"
68 preFixupPhases
+=" qtOwnPathsHook"
70 # Note: $qtWrapperArgs still gets defined even if ${dontWrapQtApps-} is set.
72 # skip this hook when requested
73 [ -z "${dontWrapQtApps-}" ] ||
return 0
75 # guard against running multiple times (e.g. due to propagation)
76 [ -z "$wrapQtAppsHookHasRun" ] ||
return 0
77 wrapQtAppsHookHasRun
=1
79 local targetDirs
=( "$prefix/bin" "$prefix/sbin" "$prefix/libexec" )
80 echo "wrapping Qt applications in ${targetDirs[@]}"
82 for targetDir
in "${targetDirs[@]}"
84 [ -d "$targetDir" ] ||
continue
86 find "$targetDir" ! -type d
-executable -print0 |
while IFS
= read -r -d '' file
88 patchelf
--print-interpreter "$file" >/dev
/null
2>&1 ||
continue
96 target
="$(readlink -e "$file")"
97 echo "wrapping $file -> $target"
99 makeQtWrapper
"$target" "$file"
105 fixupOutputHooks
+=(wrapQtAppsHook
)