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

Use impure environment for dump command #69

Closed

Conversation

jgeerds
Copy link

@jgeerds jgeerds commented Feb 23, 2021

Since /share directories of nativeBuildInputs are added to $XDG_DATA_DIRS (see direnv/direnv#443 (comment)), the original $XDG_DATA_DIRS variable (i.e. before entering the directory / loading the environment) is completely overwritten by the new one.

This just happens when using nix-direnv. The original use_nix function by direnv does not use --pure and works as expected:

use_nix() {
  direnv_load nix-shell --show-trace "$@" --run "$(join_args "$direnv" dump)"
  if [[ $# == 0 ]]; then
    watch_file default.nix shell.nix
  fi
}

This pull request fixes the issue for me.

@@ -187,7 +187,7 @@ use_nix() {
dump_cmd="echo _____direnv_____; \"$direnv\" dump bash"
tmp=$("${NIX_BIN_PREFIX}nix-shell" \
"${experimental_flags[@]}" \
--show-trace --pure "$@" --run "$dump_cmd")
--show-trace "$@" --run "$dump_cmd")
Copy link
Member

@Mic92 Mic92 Feb 23, 2021

Choose a reason for hiding this comment

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

We have to --pure otherwise we cannot cache its output since it also include the users environment.

Copy link
Member

Choose a reason for hiding this comment

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

Is there maybe a way to save the old value of XDG_DATA_DIRS and than just append the value from nix-shell?

Copy link
Contributor

Choose a reason for hiding this comment

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

I just hit this issue, should be possible to handle XDG_DATA_DIRS the same way PATH is handled in _nix_import_env()?

@meck meck mentioned this pull request Feb 27, 2021
@Mic92
Copy link
Member

Mic92 commented Feb 27, 2021

Solved in #71

@Mic92 Mic92 closed this Feb 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants