Skip to content

Commit 1385a38

Browse files
committed
fix path-info
1 parent 37626bf commit 1385a38

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

internal/nix/store.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"go.jetpack.io/devbox/internal/debug"
1414
"go.jetpack.io/devbox/internal/redact"
1515
"go.jetpack.io/devbox/nix"
16+
"go.jetpack.io/devbox/nix/flake"
1617
"golang.org/x/exp/maps"
1718
)
1819

@@ -27,6 +28,19 @@ func StorePathFromHashPart(ctx context.Context, hash, storeAddr string) (string,
2728

2829
func StorePathsFromInstallable(ctx context.Context, installable string, allowInsecure bool) ([]string, error) {
2930
defer debug.FunctionTimer().End()
31+
32+
// Some older versions of Nix have a bug where specifying a narHash
33+
// without a lastModifiedDate query parameter results in an error. I'm
34+
// not sure when it was fixed, but I know it works in 2.25+.
35+
if !nix.AtLeast(nix.Version2_25) {
36+
parsed, err := flake.ParseInstallable(installable)
37+
if err == nil {
38+
parsed.Ref.NARHash = ""
39+
parsed.Ref.LastModified = 0
40+
installable = parsed.String()
41+
}
42+
}
43+
3044
// --impure for NIXPKGS_ALLOW_UNFREE
3145
cmd := command("path-info", installable, "--json", "--impure")
3246
cmd.Env = allowUnfreeEnv(os.Environ())

0 commit comments

Comments
 (0)