-
Notifications
You must be signed in to change notification settings - Fork 264
nix: allow users to set shell startup hooks #93
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
Add a `shell.init_hook` field to devbox.json which can contain arbitrary commands to run at shell startup. { "packages": ["go"], "shell": { "init_hook": "echo hello from a hook!" } } This change also merges the `shell` package into `nix`, making it clearer that it handles Nix shells specifically. The `nix.Shell` function is replaced by the `nix.Shell` struct, which does everything that the `shell.Shell` struct did. The new API looks something like: sh, err := nix.DetectShell() sh.UserInitHook = cfg.Shell.InitHook sh.Run(nixPath) Finally, we now build the devbox shellrc with a template since it was getting a bit complex.
d0c8393
to
6d8981e
Compare
Obviously also open to suggestions on how the |
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.
LGTM, let's just agree on the right schema for devbox.json
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!
I think I could use this in the rust planner in #97: I need to call rustup default <version>
after the shell starts....
This is to make sure we don't try to use a partially-read file.
Awesome! Thank you! |
Summary
Add a
shell.init_hook
field to devbox.json which can contain arbitrary commands to run at shell startup.This change also merges the
shell
package intonix
, making it clearer that it handles Nix shells specifically. Thenix.Shell
function is replaced by thenix.Shell
struct, which does everything that theshell.Shell
struct did.The new API looks something like:
Finally, we now build the devbox shellrc with a template since it was getting a bit complex.
How was it tested?
Adding a hook and running a shell.