setup.sh: Support XDG_DATA_DIRS

XDG_DATA_DIRS is to /share as PATH is to /bin.

It was defined as part of the XDG basedir specification.
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html

While it originated from the X Desktop Group, it is not limited to
the X11 ecosystem, as evidenced by its use in bash-completion.

The removal of ` && -d "$pkg/bin"` is ok, because this optimization is
already performed by `addToSearchPath`.
This commit is contained in:
Robert Hensing 2020-11-11 16:26:06 +01:00 committed by Jonathan Ringer
parent 5b286eaf20
commit 0f13cccb95

@ -483,8 +483,9 @@ activatePackage() {
# the transition, we do include everything in thatcase.
#
# TODO(@Ericson2314): Don't special-case native compilation
if [[ ( -z "${strictDeps-}" || "$hostOffset" -le -1 ) && -d "$pkg/bin" ]]; then
if [[ -z "${strictDeps-}" || "$hostOffset" -le -1 ]]; then
addToSearchPath _PATH "$pkg/bin"
addToSearchPath _XDG_DATA_DIRS "$pkg/share"
fi
if [[ "$hostOffset" -eq 0 && -d "$pkg/bin" ]]; then
@ -602,13 +603,16 @@ fi
PATH="${_PATH-}${_PATH:+${PATH:+:}}$PATH"
HOST_PATH="${_HOST_PATH-}${_HOST_PATH:+${HOST_PATH:+:}}$HOST_PATH"
XDG_DATA_DIRS="${_XDG_DATA_DIRS-}${_XDG_DATA_DIRS:+${XDG_DATA_DIRS:+:}}${XDG_DATA_DIRS-}"
if (( "${NIX_DEBUG:-0}" >= 1 )); then
echo "final path: $PATH"
echo "final host path: $HOST_PATH"
echo "final data dirs: $XDG_DATA_DIRS"
fi
unset _PATH
unset _HOST_PATH
unset _XDG_DATA_DIRS
# Make GNU Make produce nested output.