-
Notifications
You must be signed in to change notification settings - Fork 330
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
Question: How can I create a pure shell? #330
Comments
Hey! I'm still thinking about adding support for One issue I have with it is that it removes all the tooling from your system, for example the editor, etc. Could you provide an example of the binaries that got in the env? |
Ah, good point. Could a compromise be only known critical system paths are included for $PATH? So
Sure, it's only two binaries causing problems, python and virtualenv. |
Could you explain exactly what happened and what you expected to happen? That would allow me to design this to prevent such kind of mistakes :) |
I expect the devenv.nix file, as defined below, to not let me execute { pkgs, ... }:
{
# https://devenv.sh/packages/
packages = [];
# https://devenv.sh/pre-commit-hooks/
pre-commit.hooks.shellcheck.enable = false;
} However, it was executed because it was found in my $PATH at |
We also would like to see |
This one is easy to achieve once we tackle #240 |
(Hope you don't mind my commenting)
I personally see this as a positive option, TBH. Everywhere else I've worked that aspires to hermetic builds / build-env expects the editor to be able to run things (tests, etc) inside a kind-of "dev-env sandbox" anyway, so you get the nearest thing to your CI systems result(s) as well. Those places can use things like a dev container, but sometimes that's difficult or inappropriate, so it's really helpful that |
The advantage of using |
I'm using this approach: enterShell = lib.mkMerge [
''
export IMPURE_PATH="$PATH"
''
## if we're running in pure mode, reset PATH to be _just_ from devenv
(lib.mkIf config.eval.pure ''
export PATH="$DEVENV_PROFILE/bin"
'')
]; and for commands that should call out into system tools # for example for firewall setup, restore original path
firewall-setup.exec = ''
export PATH=$IMPURE_PATH
case $(uname) in
Linux)
sudo iptables -t nat -I OUTPUT -p tcp -d 127.0.0.1 --dport 80 -j REDIRECT --to-ports 8000
sudo iptables -t nat -I OUTPUT -p tcp -d 127.0.0.1 --dport 443 -j REDIRECT --to-ports 4430
;;
Darwin)
echo "
rdr pass inet proto tcp from any to any port 80 -> 127.0.0.1 port 8080
rdr pass inet proto tcp from any to any port 443 -> 127.0.0.1 port 4430" | \
sudo pfctl -ef -
;;
esac
''; this "pure-lite" mode is already very useful for catching missed packages early. |
Another reason I want a pure shell is that
|
That one should be solved for most cases in #745 |
Is there any update on this issue? or does it remain a non-priority? |
This might be much easier using #745 |
I'm implementing this in #745 using I wonder if we should add a setting to clean-keep-vars:
- EDITOR
- ... More control over clean-keep:
vars:
- EDITOR
executables:
- vim |
I think devenv could use
|
1.0.1 now implements: clean:
enable: true
keep:
- EDITOR |
I'm going to close this, please reopen if you'd like devenv to support keeping some executables around. |
Describe the bug
Running
devenv shell
prepends the current $PATH with the devenv-profile bin directory. However, I would like a pristine $PATH with nothing inherited. This would be something similar tonix-shell --pure
.The reason is I don't want to accidentally use a binary outside of the nix store, which has happened a few times now.
To Reproduce
Run
devenv init
and thendevenv shell
. Runecho $PATH
and notice the inherited path.Version
The text was updated successfully, but these errors were encountered: