Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[staging] setup.sh: Support XDG_DATA_DIRS (bash completion in nix-shell) #103501

Merged
merged 3 commits into from
Nov 25, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion pkgs/stdenv/generic/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -483,10 +483,14 @@ 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
matthewbauer marked this conversation as resolved.
Show resolved Hide resolved
if [[ -z "${strictDeps-}" || "$hostOffset" -le -1 ]]; then
addToSearchPath _PATH "$pkg/bin"
fi

if [[ "$hostOffset" -le -1 ]]; then
addToSearchPath _XDG_DATA_DIRS "$pkg/share"
fi

if [[ "$hostOffset" -eq 0 && -d "$pkg/bin" ]]; then
addToSearchPath _HOST_PATH "$pkg/bin"
fi
Expand Down Expand Up @@ -602,13 +606,16 @@ fi

PATH="${_PATH-}${_PATH:+${PATH:+:}}$PATH"
HOST_PATH="${_HOST_PATH-}${_HOST_PATH:+${HOST_PATH:+:}}$HOST_PATH"
export XDG_DATA_DIRS="${_XDG_DATA_DIRS-}${_XDG_DATA_DIRS:+${XDG_DATA_DIRS:+:}}${XDG_DATA_DIRS-}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this going to affect wrapGAppsHook or wrapQtAppsHook in any way?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't affect those.
This variable is set in the build environment, not in the wrapper scripts.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @NixOS/freedesktop

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, so being set in the build environment, but during fixup it shouldn't be?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well it's still set during fixupPhase but it doesn't affect the wrapper writing functions. Although, it can affect call sites if they are like wrapProgram --set XDG_DATA_DIRS $XDG_DATA_DIRS, so expanding $XDG_DATA_DIRS before invoking wrapProgram, but I don't think we have that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, wrapGAppsHook uses different environment variables for populating XDG_DATA_DIRS for wrapper. So unless one of those variables is populated from XDG_DATA_DIRS (do not see any such thing when greping sh files for XDG_DATA_DIRS so it would have to be indirectly through some program).

The only possible issue that comes to mind is that it further distances the build environment from the runtime one, possibly obscuring some missing dependencies until runtime (i.e. (install)CheckPhase passes but program will crash at runtime). But perhaps the difference is huge enough already so this might not be so much worse in proportion.

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.
Expand Down