Closed Dev380 closed 3 months ago
This is starship drawing the prompt and none of the mentioned variables are exported and things work fine. I can't seem to reproduce the problem?
Wait...I just realized that this prompt is not showing the "via ❄️ impure (nix-shell-env)".
The branch I had just prior had that text.
Where flake.nix
looks as follows (you'll probably need to subtitute x86_64-darwin
for x86_64-linux
to try it):
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
};
outputs = { self, nixpkgs }: {
devShells.x86_64-darwin.default = nixpkgs.legacyPackages.x86_64-darwin.mkShell {
inputsFrom = [ nixpkgs.legacyPackages.x86_64-darwin.hello ];
};
};
}
and .envrc
contains only use flake
.
I just tried that in a fresh flake, and it doesn't seem to work still. For some reason, the path var isn't being exported correctly either in the flake I was trying to use, as all the tools I had installed in the dev shell point to the /bin version instead (I'm on arch not nixos). Perhaps this is just my issue. I installed nix-direnv with nix profile, I copy pasted the code into .config/direnv/direnvrc exactly and nothing else is in that file, .envrc only contains "use flake", and I tried both using another shell and nix-direnv-reload (which was exported correctly as it seems like only .direnv/bin was added to the path) but it did not resolve the issue.
This starts to smell like nix-direnv
isn't installed correctly.
Two options, pick one:
1) use home-manager and set programs.direnv.enable = true;
and programs.direnv.nix-direnv.enable = true
(and maybe programs.<your shell>.enable = true;
)
2) Uninstall nix-direnv from your profile and use direnv's source_url
functionality to get the latest release.
Either of these should work fine and will reduce debugging complexity. We get a lot of requests that boil down to "it wasn't installed right" or "I wasn't actually using nix-direnv", so making sure nix-direnv is installed properly is very important to getting anywhere - in fact, while testing this, I was in a state that was using the vanilla use flake implementation, so it is very easy to get it wrong...
I rebooted my system and it seems to work. I guess that was the issue, thanks.
Using the regular nix develop command and the vanilla "use flake" shows impure (nix-shell-env) in the starship prompt as expected. However, this doesn't work with nix-direnv installed. I think the environment variables $IN_NIXSHELL and $name need to be exported for it to work, is there any reason why these and also the rest of the $NIX* env variables aren't exported with nix-direnv? As far as I can tell the regular "use flake" exports them all.