- Notifications
You must be signed in to change notification settings - Fork 275
[Devbox] introduce devopt.EnvOptions #2159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
8b2b47b to 5b66556 Compare 5b66556 to 0be27b4 Compare
mikeland73 left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
| // runDevboxServicesScript invokes RunScript with the envOptions set to the appropriate | ||
| // defaults for the `devbox services` scenario. | ||
| // TODO: move to services.go | ||
| func (d *Devbox) runDevboxServicesScript(ctx context.Context, cmdArgs []string) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RunScriptWithDefaultOptions ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I'm going to leave this as is, because "default options" may not be correct or obvious-in-meaning in all scenarios. I'll modify this in a follow up to be even more Services-specific.
…ands (#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))
Suspect IssuesThis pull request was deployed and Sentry observed the following issues:
Did you find this useful? React with a 👍 or 👎 |
Summary
From the EnvOptions docblock:
This gets rid of the pseudo-global state in the
Devboxstruct where we were settingpure,preservePathStackandomitNixEnvvalues.How was it tested?
TODO:
devbox globalanddevboxomitNixEnv works as expectedpureworks as expected fordevbox shell --pure.