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
[shell] add packages within shell, leveraging nix-profile (#188)
## Summary
**Motivation:**
We can define a custom nix-profile, and install packages scoped to this
profile.
The goal is to make it easier to add packages when within devbox shell.
Currently,
users need to exit the shell and restart it for the nix package to be
installed - clearly
not ideal. With a nix-profile, if we install the package using that
profile, then the
package's binary should be downloaded and visible within the shell.
Within `devbox shell`:
- previously, we would manually add the path to each package to `PATH`.
- now, we can add the path to the nix-profile to `PATH` and skip
manually adding each package.
**Limitations:**
1. For `devbox add` within a `devbox shell`, the user needs to manually
execute `hash -r` to ensure the latest binaries are visible.
2. ~For `devbox rm` within a `devbox shell`, the user still needs to
restart the shell. I'm not quite sure why the `nix-env --profile
<profile dir> --uninstall <pkg>` isn't working as intended.~ Fixed via
reapplying `nix-env --profile <profile> -if development.nix`
3. `devbox add` and `rm` when in a shell started from a parent directory
will not work.
- A possible fix is to set `DEVBOX_CONFIG_DIR` env-var when inside a
shell, and use that value in `devbox add` and `rm`.
- Example:
```
> cd testdata/rust/
> devbox shell rust-stable
(devbox)> devbox add go_1_18
Error: No devbox.json found in this directory, or any parent directories. Did you run `devbox init` yet?
```
## How was it tested?
- [x] in `testdata/rust/rust-stable`:
- open `devbox shell`
- verify openssl not installed via `which openssl` and getting
`/usr/bin/openssl`
- do `devbox add openssl`
- note that `which openssl` still reflects the non nix-store location.
It has NOT yet been updated.
- do `hash -r` and then `which openssl` and see it point to a nix-store
location
- do `devbox rm openssl`
- note that `which openssl` still reflects the nix-store location. It
has NOT yet been updated.
- restart `devbox shell` and do `which openssl` to verify it has been
removed
0 commit comments