Skip to content

Commit 7648993

Browse files
authored
[CLI] Changed default nix bash to bashInteractive (#1223)
## Summary In `shellPath()` function where we decide which type of shell to use when dropping user in devbox shell, if we can't figure out the shell, we drop the user in the default `bash` that nix installs in store. But this bash doesn't handle arrow keys and keyboard combinations very well, so it creates a frustrating experience for users (including pure shell users). `bashInteractive` package has all these capabilities and makes the experience better for a 'default' shell. So this PR changes this: - `nix eval <bash>` to get store path and use to create default shell to this: - `nix eval <bashInteractive>` to get store path - nix build <generated store path> - use store path to create default shell Addresses #1193 ## How was it tested? - compile - ./devbox shell --pure OR - unset $SHELL - ./devbox shell
1 parent d92f6cb commit 7648993

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

internal/impl/shell.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func shellPath(devbox *Devbox) (path string, err error) {
113113

114114
cmd := exec.Command(
115115
"nix", "eval", "--raw",
116-
fmt.Sprintf("%s#bash", nix.FlakeNixpkgs(devbox.cfg.NixPkgsCommitHash())),
116+
fmt.Sprintf("%s#bashInteractive", nix.FlakeNixpkgs(devbox.cfg.NixPkgsCommitHash())),
117117
)
118118
cmd.Args = append(cmd.Args, nix.ExperimentalFlags()...)
119119
out, err := cmd.Output()
@@ -122,6 +122,14 @@ func shellPath(devbox *Devbox) (path string, err error) {
122122
}
123123
bashNixStorePath = string(out)
124124

125+
// install bashInteractive in nix/store without creating a symlink to local directory (--no-link)
126+
cmd = exec.Command("nix", "build", bashNixStorePath, "--no-link")
127+
cmd.Args = append(cmd.Args, nix.ExperimentalFlags()...)
128+
err = cmd.Run()
129+
if err != nil {
130+
return "", errors.WithStack(err)
131+
}
132+
125133
if bashNixStorePath != "" {
126134
// the output is the raw path to the bash installation in the /nix/store
127135
return fmt.Sprintf("%s/bin/bash", bashNixStorePath), nil

0 commit comments

Comments
 (0)