Skip to content

Commit

Permalink
pipe nix-shell env through buil;d task
Browse files Browse the repository at this point in the history
  • Loading branch information
Equanox committed Jan 22, 2024
1 parent 46e9719 commit 007ab63
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions bob/nix-builder/nix_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package nixbuilder

import (
"fmt"
"os"

"github.com/benchkram/bob/pkg/boblog"
"github.com/benchkram/bob/pkg/envutil"
"github.com/benchkram/bob/pkg/file"
"github.com/benchkram/bob/pkg/filehash"
"github.com/benchkram/errz"

"github.com/benchkram/bob/bob/bobfile"
Expand Down Expand Up @@ -101,9 +101,9 @@ func (n *NB) BuildNixDependencies(ag *bobfile.Bobfile, buildTasksInPipeline, run
nixShellEnv, err := nix.NixShell(ag.Shell)
errz.Fatal(err)

f, err := os.ReadFile(ag.Shell)
hash, err := filehash.Hash(ag.Shell)
errz.Fatal(err)
hash := envutil.Hash(string(f))

n.envStore[envutil.Hash(hash)] = nixShellEnv
for _, name := range buildTasksInPipeline {
t := ag.BTasks[name]
Expand Down
4 changes: 2 additions & 2 deletions pkg/nix/nix.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,21 +349,21 @@ func NixShell(path string) ([]string, error) {
args = append(args, []string{"--pure", "--command", "env"}...)
args = append(args, path)
cmd := exec.Command("nix-shell", args...)
boblog.Log.V(5).Info(fmt.Sprintf("Executing command:\n %s", cmd.String()))

var out bytes.Buffer
var errBuf bytes.Buffer
cmd.Stdout = &out
cmd.Stderr = &errBuf

env := strings.Split(out.String(), "\n")
err := cmd.Run()
if err != nil {
return nil, prepareRunError(err, cmd.String(), errBuf)
}

// if NIX_SSL_CERT_FILE && SSL_CERT_FILE are set to /no-cert-file.crt unset them
var clearedEnv []string
for _, e := range env {
for _, e := range strings.Split(out.String(), "\n") {
pair := strings.SplitN(e, "=", 2)
if pair[0] == "NIX_SSL_CERT_FILE" && pair[1] == "/no-cert-file.crt" {
continue
Expand Down

0 comments on commit 007ab63

Please sign in to comment.