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[@]}"; do
11 if [ "${pkg:?}" == "$1" ]; then
16 qtHostPathSeen
+=("$1")
21 qtUnseenHostPath
"$1" ||
return 0
23 if ! [ -v qtPluginPrefix
]; then
24 echo "wrapQtAppsHook qtHostPathHook: qtPluginPrefix is unset. hint: add qt6.qtbase to buildInputs"
27 local pluginDir
="$1/${qtPluginPrefix:?}"
28 if [ -d "$pluginDir" ]; then
29 qtWrapperArgs
+=(--prefix QT_PLUGIN_PATH
: "$pluginDir")
32 local qmlDir
="$1/${qtQmlPrefix:?}"
33 if [ -d "$qmlDir" ]; then
34 qtWrapperArgs
+=(--prefix QML2_IMPORT_PATH
: "$qmlDir")
37 addEnvHooks
"$targetOffset" qtHostPathHook
43 makeWrapper
"$original" "$wrapper" "${qtWrapperArgs[@]}" "$@"
49 wrapProgram
"$program" "${qtWrapperArgs[@]}" "$@"
53 local xdgDataDir
="${!outputBin}/share"
54 if [ -d "$xdgDataDir" ]; then
55 qtWrapperArgs
+=(--prefix XDG_DATA_DIRS
: "$xdgDataDir")
58 local xdgConfigDir
="${!outputBin}/etc/xdg"
59 if [ -d "$xdgConfigDir" ]; then
60 qtWrapperArgs
+=(--prefix XDG_CONFIG_DIRS
: "$xdgConfigDir")
63 qtHostPathHook
"${!outputBin}"
66 preFixupPhases
+=" qtOwnPathsHook"
68 # Note: $qtWrapperArgs still gets defined even if ${dontWrapQtApps-} is set.
70 # skip this hook when requested
71 [ -z "${dontWrapQtApps-}" ] ||
return 0
73 # guard against running multiple times (e.g. due to propagation)
74 [ -z "$wrapQtAppsHookHasRun" ] ||
return 0
75 wrapQtAppsHookHasRun
=1
77 local targetDirs
=("$prefix/bin" "$prefix/sbin" "$prefix/libexec" "$prefix/Applications" "$prefix/"*.app
)
78 echo "wrapping Qt applications in ${targetDirs[@]}"
80 for targetDir
in "${targetDirs[@]}"; do
81 [ -d "$targetDir" ] ||
continue
83 find "$targetDir" ! -type d
-executable -print0 |
while IFS
= read -r -d '' file; do
84 if [ -f "$file" ]; then
87 elif [ -h "$file" ]; then
88 target
="$(readlink -e "$file")"
89 echo "wrapping $file -> $target"
91 makeQtWrapper
"$target" "$file"
97 fixupOutputHooks
+=(wrapQtAppsHook
)