Open storvik opened 2 years ago
Oddly the expression evaluates perfectly fine in a nix repl, I wish nix-instantiate would give useful errors...
I'm having the same issues. It seems to affect not only all private repos, but also public ones where the module ref doesn't correspond to a released version (updating to a given commit or branch — e.g., go get example.net/fake/mod@branch
).
For example, I'm getting this (upon gomod2nix import
) in one of my projects:
INFO[0000] Importing sources goPackagePath=golang.org/x/oauth2
error: path '/nix/store/m5x1qfq4yqdn8zyx4gm4z12m112mmj9b-oauth2_v0.0.0-20220411215720-9780585627b5' is not valid
(use '--show-trace' to show detailed location information)
/run/current-system/sw/bin/nix-instantiate --eval --expr
builtins.filterSource (name: type: baseNameOf name != ".DS_Store") (
builtins.path {
path = "/home/jt/go/pkg/mod/golang.org/x/oauth2@v0.0.0-20220411215720-9780585627b5";
name = "oauth2_v0.0.0-20220411215720-9780585627b5";
}
)
Like @jgresty said, running it in nix repl
works (and, moreover, resolves the issue for future invocations).
Another way around it is to run nix-instantiate
without --eval
first, like so (original+show-trace, no eval+show-trace, original+show-trace):
$ /run/current-system/sw/bin/nix-instantiate --eval --expr 'builtins.filterSource (name: type: baseNameOf name != ".DS_Store") (
builtins.path {
path = "/home/jt/go/pkg/mod/golang.org/x/oauth2@v0.0.0-20220411215720-9780585627b5";
name = "oauth2_v0.0.0-20220411215720-9780585627b5";
}
)' --show-trace
error: path '/nix/store/m5x1qfq4yqdn8zyx4gm4z12m112mmj9b-oauth2_v0.0.0-20220411215720-9780585627b5' is not valid
… while adding path '/nix/store/m5x1qfq4yqdn8zyx4gm4z12m112mmj9b-oauth2_v0.0.0-20220411215720-9780585627b5'
at «string»:1:1:
1| builtins.filterSource (name: type: baseNameOf name != ".DS_Store") (
| ^
2| builtins.path {
$ /run/current-system/sw/bin/nix-instantiate --expr 'builtins.filterSource (name: type: baseNameOf name != ".DS_Store") (
builtins.path {
path = "/home/jt/go/pkg/mod/golang.org/x/oauth2@v0.0.0-20220411215720-9780585627b5";
name = "oauth2_v0.0.0-20220411215720-9780585627b5";
}
)' --show-trace
error: expression does not evaluate to a derivation (or a set or list of those)
$ /run/current-system/sw/bin/nix-instantiate --eval --expr 'builtins.filterSource (name: type: baseNameOf name != ".DS_Store") (
builtins.path {
path = "/home/jt/go/pkg/mod/golang.org/x/oauth2@v0.0.0-20220411215720-9780585627b5";
name = "oauth2_v0.0.0-20220411215720-9780585627b5";
}
)' --show-trace
"/nix/store/c7z9bm9qzashlcqiv5v2jwcch6gq2hwv-m5x1qfq4yqdn8zyx4gm4z12m112mmj9b-oauth2_v0.0.0-20220411215720-9780585627b5"
I haven't looked at the gomod2nix import
code, but I imagine it wouldn't be too difficult to update it to make it work (I'm not sure whether it can be done in a single invocation of nix-instantiate
, or not, or even whether it's better to run something else here).
🤷
I just noticed that I'm also getting
error: path '/nix/store/mqn6p2m3qvzqwan59c3xlyvjxgjjhyhy-sys_v0.1.0' is not valid
(use '--show-trace' to show detailed location information)
/run/current-system/sw/bin/nix-instantiate --eval --expr
builtins.filterSource (name: type: baseNameOf name != ".DS_Store") (
builtins.path {
path = "/home/jt/go/pkg/mod/golang.org/x/sys@v0.1.0";
name = "sys_v0.1.0";
}
)
so I'm guessing that it's actually more general/not specific to the handling of private or untagged module versions.
It looks like nix eval --impure --expr ...
would be a suitable replacement (but would require a semi-recent nix
version — OTOH, it would work).
@storvik, I should probably have reread your original issue description before trying to add my own notes/comments. I just reread now and saw where you said (only three sentences in, even) that it wasn't specific to private (or untagged) repos (and refs), but I already came here having discovered the same issue from working with private modules, and just latched on to that instead.
Still, either using nix eval --impure --expr ...
or nix-instantiate --expr ...; nix-instantiate --eval --expr ...
should work.
Trying to use this to build a go package using some private modules. Looks like I should be able to do that using
generate
andimport
, but getting error path is not valid. Tried without private modules and the problem persists.Describe the bug nix-instantiate returns
error: path /nix/store/*hash*-*package* is not valid.
when runninggomod2nix import
.To Reproduce
Expected behavior Expected go dependencies to be imported into the nix store.
Environment
Tested both OS but the same thing happened.
Additional context The complete log is here
I've tried to run the nix-instantiate command manually too, but same error.
A working solution to use private repos would be great, this is a promising start. Thanks for your contributions to the community.