-
Notifications
You must be signed in to change notification settings - Fork 227
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
Include some more shell-specific vars, remove nix shell hook #635
Conversation
internal/impl/devbox.go
Outdated
env[name] = os.Getenv(name) | ||
// Copy over (and overwrite) vars that we explicitly "leak", as well as DEVBOX_ vars. | ||
for _, kv := range os.Environ() { | ||
parts := strings.SplitN(kv, "=", 2) |
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.
key, val, found := strings.Cut(kv, "=")
if !found {
return errors.Errorsf("expected = in kv: %s", kv)
}
} | ||
} | ||
|
||
// These variables are only needed for shell, but we include them here in the computed env | ||
// for both shell and run in order to be as identical as possible. | ||
env["NIX_PKGS_ALLOW_UNFREE"] = "1" // Only for shell because we don't expect nix calls within run |
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.
I think its good to include, because someone's script may do devbox add
for them.
// TODO: add shell-specific vars, including: | ||
// - NIXPKGS_ALLOW_UNFREE=1 (not needed in run because we don't expect nix calls there) | ||
// - __ETC_PROFILE_NIX_SOURCED=1 (not needed in run because we don't expect rc files to try to load nix profiles) | ||
// - HISTFILE (not needed in run because it's non-interactive) |
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.
would it be good to maintain somewhere a list of env vars like HISTFILE that are deliberately omitted from devbox run
but included in devbox shell
?
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.
maybe in LeakedVarsForShell with a value of false
?
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.
Well, I think looking at shellrc will be good enough for now (there's no other place in which the env can be changed)
71481b5
to
a1de3c8
Compare
## Summary #635 hid the shell hook from `shell.nix` behind the unified-env flag (where shell hook is active when flag is OFF). So, this PR removes it from `flake.nix`, since flakes depend on unified-env being turned on. ## How was it tested? opened `devbox shell` in `examples/testdata/go/go-1.19` project
## Summary This was introduced in #635 (cc @ipince). I don't think its needed anymore. It seems to be used in the `/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh` script, at the very top to prevent re-execution: ``` 1 # Only execute this file once per shell. 2 if [ -n "${__ETC_PROFILE_NIX_SOURCED:-}" ]; then return; fi 3 __ETC_PROFILE_NIX_SOURCED=1 4 ``` Perhaps it has other use-cases as well? RFC. From my casual usage of a Devbox binary built with this change, it all seems to still work fine. ## How was it tested?
Summary
Add some more variables that are required for shell: DEVBOX_ vars, a couple hard-coded nix vars, and a few more vars to leak.
Also removes the
shell.nix
hook, which we no longer need if we're using unified env.How was it tested?
go tests