Skip to content

Commit

Permalink
bring back shell.nix (#927)
Browse files Browse the repository at this point in the history
## 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
  ];
}
```
  • Loading branch information
savil authored Apr 19, 2023
1 parent 9386506 commit 9645d48
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
12 changes: 11 additions & 1 deletion internal/impl/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,30 @@ import (
//go:embed tmpl/*
var tmplFS embed.FS

var shellFiles = []string{"shell.nix"}

func (d *Devbox) generateShellFiles() error {

plan, err := d.ShellPlan()
if err != nil {
return err
}

outPath := filepath.Join(d.projectDir, ".devbox/gen")

for _, file := range shellFiles {
err := writeFromTemplate(outPath, plan, file)
if err != nil {
return errors.WithStack(err)
}
}

// Gitignore file is added to the .devbox directory
err = writeFromTemplate(filepath.Join(d.projectDir, ".devbox"), plan, ".gitignore")
if err != nil {
return errors.WithStack(err)
}

outPath := filepath.Join(d.projectDir, ".devbox/gen")
err = makeFlakeFile(outPath, plan)
if err != nil {
return errors.WithStack(err)
Expand Down
21 changes: 21 additions & 0 deletions internal/impl/tmpl/shell.nix.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
let
pkgs = import
(fetchTarball {
url = "{{ .NixpkgsInfo.URL }}";
{{- if .NixpkgsInfo.Sha256 }}
sha256 = "{{ .NixpkgsInfo.Sha256 }}";
{{- end }}
})
{ };
{{- range .Definitions}}
{{.}}
{{ end }}
in
with pkgs;
mkShell {
packages = [
{{- range .DevPackages}}
{{.}}
{{- end }}
];
}

0 comments on commit 9645d48

Please sign in to comment.