Skip to content

Commit 9645d48

Browse files
authored
bring back shell.nix (#927)
## Summary We can bring back the `shell.nix` file to ensure older .envrc files work. ## How was it tested? did `devbox shell` and saw that `.devbox/gen/shell.nix` exists. ``` ❯ cat .devbox/gen/shell.nix let pkgs = import (fetchTarball { url = "https://github.com/nixos/nixpkgs/archive/3364b5b117f65fe1ce65a3cdd5612a078a3b31e3.tar.gz"; }) { }; in with pkgs; mkShell { packages = [ go_1_20 golangci-lint actionlint ]; } ```
1 parent 9386506 commit 9645d48

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

internal/impl/generate.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,30 @@ import (
2424
//go:embed tmpl/*
2525
var tmplFS embed.FS
2626

27+
var shellFiles = []string{"shell.nix"}
28+
2729
func (d *Devbox) generateShellFiles() error {
2830

2931
plan, err := d.ShellPlan()
3032
if err != nil {
3133
return err
3234
}
3335

36+
outPath := filepath.Join(d.projectDir, ".devbox/gen")
37+
38+
for _, file := range shellFiles {
39+
err := writeFromTemplate(outPath, plan, file)
40+
if err != nil {
41+
return errors.WithStack(err)
42+
}
43+
}
44+
3445
// Gitignore file is added to the .devbox directory
3546
err = writeFromTemplate(filepath.Join(d.projectDir, ".devbox"), plan, ".gitignore")
3647
if err != nil {
3748
return errors.WithStack(err)
3849
}
3950

40-
outPath := filepath.Join(d.projectDir, ".devbox/gen")
4151
err = makeFlakeFile(outPath, plan)
4252
if err != nil {
4353
return errors.WithStack(err)

internal/impl/tmpl/shell.nix.tmpl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
let
2+
pkgs = import
3+
(fetchTarball {
4+
url = "{{ .NixpkgsInfo.URL }}";
5+
{{- if .NixpkgsInfo.Sha256 }}
6+
sha256 = "{{ .NixpkgsInfo.Sha256 }}";
7+
{{- end }}
8+
})
9+
{ };
10+
{{- range .Definitions}}
11+
{{.}}
12+
{{ end }}
13+
in
14+
with pkgs;
15+
mkShell {
16+
packages = [
17+
{{- range .DevPackages}}
18+
{{.}}
19+
{{- end }}
20+
];
21+
}

0 commit comments

Comments
 (0)