Skip to content

Commit e365220

Browse files
committed
nixbuild/instantiateDrvPath: parse json
1 parent a7a5e7e commit e365220

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/nixbuild.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package main
33
import (
44
"encoding/json"
55
"fmt"
6-
"strings"
76
)
87

98
// model 'nix build --json' output.
@@ -84,12 +83,15 @@ func instantiateDrvPath(flake string, name string, builder string) (string, erro
8483
drvExpr := expr + ".drvPath"
8584

8685
// Evaluate the .drv path locally
87-
data, err := runJSON("nix", "eval", "--raw", drvExpr)
86+
data, err := runJSON("nix", "eval", "--json", drvExpr)
8887
if err != nil {
8988
return "", fmt.Errorf("failed to evaluate drvPath for job '%s': %w", name, err)
9089
}
9190

92-
drvPath := strings.TrimSpace(string(data))
91+
var drvPath string
92+
if err := json.Unmarshal(data, &drvPath); err != nil {
93+
return "", fmt.Errorf("failed to parse JSON for job '%s': %w", name, err)
94+
}
9395

9496
// Copy the .drv to the remote builder (if needed)
9597
if builder != "localhost" {

0 commit comments

Comments
 (0)