devbox
devbox copied to clipboard
[Bug]: nix-shell -p <pkg> does not take effect when on devbox global
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
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