Skip to content

Commit 07739a7

Browse files
authored
[shell] minimal revert of #222 to bring back shell plans temporarily (#228)
## Summary Until we can land #227, I want to revert the changes in #222 so that shell plans can continue working, and we can release some other (unrelated) fixes. In this PR, I revert (manually) the `devbox.go` changes in #222, while leaving the test changes to minimize merge conflicts with #227. cc @loreto @LucilleH ## How was it tested? sanity check ``` > cd testdata/nodejs/nodejs-18 > devbox shell > which node # get nix store path > exit ``` - [x] will find an example with init-hooks and test that. Example 1: nginx ``` > devbox shell Installing nix packages. This may take a while...done. Starting a devbox shell... ##### WARNING: nginx planner is experimental ##### You may need to add "include ./.devbox/gen/shell-helper-nginx.conf;" to your shell-nginx.conf file to ensure the server can start in the nix shell. Use "shell-nginx" to start the server ``` Example 2: python/pip-example ``` devbox/testdata/python/pip-example > devbox shell Installing nix packages. This may take a while...done. Starting a devbox shell... Creating/Using virtual environment in /Users/savil/code/jetpack/devbox/testdata/python/pip-example/.venv (devbox) devbox/testdata/python/pip-example > which python3 /Users/savil/code/jetpack/devbox/testdata/python/pip-example/.venv/bin/python3 ```
1 parent 8811ade commit 07739a7

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

devbox.go

+21-4
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,13 @@ func (d *Devbox) Build(flags *docker.BuildFlags) error {
137137

138138
// Plan creates a plan of the actions that devbox will take to generate its
139139
// shell environment.
140-
func (d *Devbox) ShellPlan() *plansdk.Plan {
141-
// TODO: Move shell plan to a separate struct from build plan.
142-
return d.convertToPlan()
140+
func (d *Devbox) ShellPlan() (*plansdk.Plan, error) {
141+
userPlan := d.convertToPlan()
142+
shellPlan, err := planner.GetShellPlan(d.srcDir)
143+
if err != nil {
144+
return nil, err
145+
}
146+
return plansdk.MergeUserPlan(userPlan, shellPlan)
143147
}
144148

145149
// Plan creates a plan of the actions that devbox will take to generate its
@@ -172,13 +176,19 @@ func (d *Devbox) Shell() error {
172176
return err
173177
}
174178

179+
plan, err := d.ShellPlan()
180+
if err != nil {
181+
return errors.WithStack(err)
182+
}
183+
175184
profileDir, err := d.profileDir()
176185
if err != nil {
177186
return err
178187
}
179188

180189
nixShellFilePath := filepath.Join(d.srcDir, ".devbox/gen/shell.nix")
181190
sh, err := nix.DetectShell(
191+
nix.WithPlanInitHook(plan.ShellInitHook),
182192
nix.WithProfile(profileDir),
183193
nix.WithHistoryFile(filepath.Join(d.srcDir, shellHistoryFile)),
184194
)
@@ -245,7 +255,14 @@ func (d *Devbox) convertToPlan() *plansdk.Plan {
245255
}
246256

247257
func (d *Devbox) generateShellFiles() error {
248-
return generate(d.srcDir, d.ShellPlan(), shellFiles)
258+
shellPlan, err := d.ShellPlan()
259+
if err != nil {
260+
return err
261+
}
262+
if shellPlan.Invalid() {
263+
return shellPlan.Error()
264+
}
265+
return generate(d.srcDir, shellPlan, shellFiles)
249266
}
250267

251268
func (d *Devbox) generateBuildFiles() error {

0 commit comments

Comments
 (0)