Closed Vonfry closed 2 years ago
Can confirm.
This totally breaks xdg-open
for me.
It’s not done by lorri, but rather the nix-shell
will set that variable and override the existing one.
We could maybe do something custom, but idk how reasonable that is.
Ok.
How does nix-shell
determine how to set XDG_DATA_DIRS
?
Becuase inside a normal nix-shell xdg-open
works just fine.
(In a --pure shell it does not work as expected, but differently from inside lorri)
Also: Before updating my nixos to 21-05 I never had problems with xdg-open in lorri, so something must have changed in lorri, nix-shell or somewhere else in nixos.
How does
nix-shell
determine how to setXDG_DATA_DIRS
?
I don’t know how much nix intuition you have, but Actually, I’m not sure.nix-shell
(and by extension lorri, more or less) just goes into the nix builder scope, which sets the environment as it is declared in the nix .drv
file.
In your project, run
nix-shell -p haskellPackages.nix-derivation --run "pretty-derivation < $(nix-instantiate shell.nix)" | less
To see a pretty-printed version of your shell’s drv file.
However, I don’t see any mention of XDG_* in there, and it still overwrites it in lorri direnv
, while prepending in nix-shell
(without --pure
).
So obviously it is set somewhere, but I wasn’t able to reconstruct where it comes from so far. It’s been a while since I thought about these parts of lorri and the nixpkgs stdenv
. Maybe just appending it to the magic list in
might do the trick.
The resetting of XDG_DATA_DIRS also breaks git's bash-completion if it hasn't been loaded before entering the project with lorri direnv. If I move away the lorri calling .envrc and enter the a nix-shell directly, this does not happen. I.e. XDG_DATA_DIRS keeps its value. In general lorri seems to set all environment variables available during package build.
declare -x NIX_BINTOOLS="/nix/store/wp3f8kbdaw6hm6k40yp0cpxnvs6dqqk9-binutils-wrapper-2.35.1" declare -x NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu="1" declare -x NIX_BUILD_CORES="32" declare -x NIX_BUILD_TOP="/build" declare -x NIX_CC="/nix/store/gg2rq3hrl3rf92nq6dnqhdyyxaa89aqf-gcc-wrapper-10.3.0" declare -x NIX_CC_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu="1" declare -x NIX_CFLAGS_COMPILE=" -frandom-seed=3if9ky04z2 -isystem /nix/store/iln9cv58v7cfizsw2a6yczny2bbqxyx8-adoptopenjdk-hotspot-bin-11.0.10/include -isystem /nix/store/iln9cv58v7cfizsw2a6yczny2bbqxyx8-adoptopenjdk-hotspot-bin-11.0.10/include" declare -x NIX_ENFORCE_NO_NATIVE="1" declare -x NIX_ENFORCE_PURITY="1" declare -x NIX_HARDENING_ENABLE="fortify stackprotector pic strictoverflow format relro bindnow"
To me it seems questionable that this approach is worthwhile. lorri maintains a list of variable to not redefine. But that leads to a whack-a-mole game to filter out all environment variables that should not end up in direnv.
Also running into this, it only started on Nixos 21.05 - was fine on 20.09. It makes lorri sort of unusable.
It’s not done by lorri, but rather the
nix-shell
will set that variable and override the existing one.We could maybe do something custom, but idk how reasonable that is.
I'm on nix v2.9.1 and nix-shell
not overwrite XDG_DATA_DIRS
(it correctly adds to it), however lorri shell
does
> lorri --version
lorri 1.5.0
https://github.com/nix-community/lorri/pull/61 claims to fix this but doesn't seem like there has been an official release since then and it has not been propagated to nixpkgs
Describe the bug
XDG_DATA_DIRS
is overrided which breaks actions likexdg-open
with custommimeapps.list
.To Reproduce Steps to reproduce the behavior:
lorri init
patchelf
echo $XDG_DATA_DIRS
echo $XDG_DATA_DIRS
Expected behavior
Some variable should not be override or append with its old value like
XDG_DATA_DIRS
.Metadata
Additional context
nix-direnv doesn't have the problem. It do sth like this.