devbox icon indicating copy to clipboard operation
devbox copied to clipboard

[Bug]: nix-shell -p <pkg> does not take effect when on devbox global

Open rbelem opened this issue 2 years ago • 1 comments

Current Behavior (bug) When using devbox global on NixOS, nix-shell -p 'pkg' does not take effect.

Expected Behavior (fix) The binaries for the packages should be available after running nix-shell -p .

Additional context

Version:     0.8.5
Platform:    linux_amd64
Commit:      none
Commit Time: unknown
Go Version:  go1.21.5
Launcher:

My devbox.json

rbelem avatar Dec 26 '23 02:12 rbelem

Looks like this happens because nix-shell -p <pkg> works by setting the buildInputs env var to the specified packages. The problem is that the shell sources ~/.bashrc, which runs eval "$(devbox global shellenv)", which overwrites the existing buildInputs environment variable. We need to make Devbox merge them to preserve any packages set with -p.

As a workaround, try adding a check to your ~/.bashrc:

# Only eval devbox global when not in a nix-shell.
if [ -z $IN_NIX_SHELL ]; then
        eval "$(devbox global shellenv)"
fi

gcurtis avatar Jan 09 '24 22:01 gcurtis