You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[devbox global] add --omit-nix-env flag for shellenv/shell/run commands (#2150)
…vars
## Summary
In this PR, we change `devbox global` shell environment to omit the
env-vars from `nix print-dev-env`. Instead, we rely on the `nix profile`
that Devbox manages to introduce the global packages into `PATH`. As
before, `nix profile` continues to be generated from the `buildInputs`
from `nix print-dev-env <devbox-generated-flake>`.
The motivation is:
1. `devbox global` adds a bunch of nix stdenv packages to the top of
your `$PATH` variable, which can cause conflicts when trying to compile
or build projects on your machine.
2. `devbox global` also sets a global `PYTHONPATH` variable that
interferes with other packages, as well as python scripts that are
installed/running on the host. This global `PYTHONPATH` is unnecessary
because any python binaries installed by the user are already wrapped
with the `PYTHONPATH`
Implementation notes:
- Sets `Devbox.envForPackageBins` boolean setting that controls whether
the Devbox Environment is optimized for executing package binaries, or
for developing software using the packages.
- [x] see if this can be passed down as a function parameter (see #2159)
- Adds `flagDefaultOptions` to `shellEnvCmd`. This is a nicer way of
overriding the defaults in global, even for the `--recompute` flag that
we had done before.
- Refactors code into a `devbox.execPrintDevEnv` function to remove some
of the complexity from the `devbox.computeEnv` function (thanks to
finger-wagging by our linter tool ;) ).
TODO:
- [x] Verify `omitNixEnv` is still properly handling the
useNixPrintDevEnvCache call paths
## How was it tested?
CICD tests should pass
TODO:
- [x] Ensure the python global scenario works
- [x] Ensure we can use common packages (fzf, ripgrep, etc.) in `devbox
global`
- [x] Thanks to @gcurtis vetted this PR helps resolve issues with a
couple of repos:
(rust: https://github.com/zed-industries/zed.git) and (golang with cgo:
[github.com/Code-Hex/vz/example/macOS](http://github.com/Code-Hex/vz/example/macOS))
&flags.pure, "pure", false, "if this flag is specified, devbox runs the script in an isolated environment inheriting almost no variables from the current environment. A few variables, in particular HOME, USER and DISPLAY, are retained.")
51
58
command.Flags().BoolVarP(
52
59
&flags.listScripts, "list", "l", false, "list all scripts defined in devbox.json")
&flags.printEnv, "print-env", false, "print script to setup shell environment")
42
49
command.Flags().BoolVar(
43
50
&flags.pure, "pure", false, "if this flag is specified, devbox creates an isolated shell inheriting almost no variables from the current environment. A few variables, in particular HOME, USER and DISPLAY, are retained.")
0 commit comments