···66accumulateRoles
7788for var in "${var_templates_list[@]}"; do
99- mangleVarList "$var" ${role_suffixes[@]+"${role_suffixes[@]}"}
99+ mangleVarListGeneric ":" "$var" ${role_suffixes[@]+"${role_suffixes[@]}"}
1010done
11111212export NIX_PKG_CONFIG_WRAPPER_FLAGS_SET_@suffixSalt@=1
+8-2
pkgs/build-support/wrapper-common/utils.bash
···1313 fi
1414}
15151616-mangleVarList() {
1616+mangleVarListGeneric() {
1717+ local sep="$1"
1818+ shift
1719 local var="$1"
1820 shift
1921 local -a role_suffixes=("$@")
···2527 for suffix in "${role_suffixes[@]}"; do
2628 local inputVar="${var}${suffix}"
2729 if [ -v "$inputVar" ]; then
2828- export ${outputVar}+="${!outputVar:+ }${!inputVar}"
3030+ export ${outputVar}+="${!outputVar:+$sep}${!inputVar}"
2931 fi
3032 done
3333+}
3434+3535+mangleVarList() {
3636+ mangleVarListGeneric " " "$@"
3137}
32383339mangleVarBool() {
···11+# This hook ensures that we do the following in post-fixup:
22+# * wrap any installed executables with a wrapper that configures TCLLIBPATH
33+# * write a setup hook that extends the TCLLIBPATH of any anti-dependencies
44+55+# Add a directory to TCLLIBPATH, provided that it exists
66+_addToTclLibPath() {
77+ local tclPkg="$1"
88+ if [[ -z "$tclPkg" ]]; then
99+ return
1010+ fi
1111+1212+ if [[ ! -d "$tclPkg" ]]; then
1313+ >&2 echo "can't add $tclPkg to TCLLIBPATH; that directory doesn't exist"
1414+ exit 1
1515+ fi
1616+1717+ if [[ "$tclPkg" == *" "* ]]; then
1818+ tclPkg="{$tclPkg}"
1919+ fi
2020+2121+ if [[ -z "${TCLLIBPATH-}" ]]; then
2222+ export TCLLIBPATH="$tclPkg"
2323+ else
2424+ if [[ "$TCLLIBPATH" != *"$tclPkg "* && "$TCLLIBPATH" != *"$tclPkg" ]]; then
2525+ export TCLLIBPATH="${TCLLIBPATH} $tclPkg"
2626+ fi
2727+ fi
2828+}
2929+3030+# Locate any directory containing an installed pkgIndex file
3131+findInstalledTclPkgs() {
3232+ local -r newLibDir="${!outputLib}/lib"
3333+ if [[ ! -d "$newLibDir" ]]; then
3434+ >&2 echo "Assuming no loadable tcl packages installed ($newLibDir does not exist)"
3535+ return
3636+ fi
3737+ echo "$(find "$newLibDir" -name pkgIndex.tcl -exec dirname {} \;)"
3838+}
3939+4040+# Wrap any freshly-installed binaries and set up their TCLLIBPATH
4141+wrapTclBins() {
4242+ if [[ -z "${TCLLIBPATH-}" ]]; then
4343+ echo "skipping automatic Tcl binary wrapping (nothing to do)"
4444+ return
4545+ fi
4646+4747+ local -r tclBinsDir="${!outputBin}/bin"
4848+ if [[ ! -d "$tclBinsDir" ]]; then
4949+ echo "No outputBin found, not using any TCLLIBPATH wrapper"
5050+ return
5151+ fi
5252+5353+ find "$tclBinsDir" -type f -executable -print |
5454+ while read -r someBin; do
5555+ echo "Adding TCLLIBPATH wrapper for $someBin"
5656+ wrapProgram "$someBin" --prefix TCLLIBPATH ' ' "$TCLLIBPATH"
5757+ done
5858+}
5959+6060+# Generate hook to adjust TCLLIBPATH in anti-dependencies
6161+writeTclLibPathHook() {
6262+ local -r hookPath="${!outputLib}/nix-support/setup-hook"
6363+ mkdir -p "$(dirname "$hookPath")"
6464+6565+ typeset -f _addToTclLibPath >> "$hookPath"
6666+ local -r tclPkgs=$(findInstalledTclPkgs)
6767+ while IFS= read -r tclPkg; do
6868+ echo "_addToTclLibPath \"$tclPkg\"" >> "$hookPath"
6969+ _addToTclLibPath "$tclPkg" true
7070+ done <<< "$tclPkgs"
7171+}
7272+7373+postFixupHooks+=(writeTclLibPathHook)
7474+postFixupHooks+=(wrapTclBins)