goDeps: support fetchFromGitHub to fetch Go libs#19311
Conversation
|
@kamilchm, thanks for your PR! By analyzing the history of the files in this pull request, we identified @wkennington, @ehmry and @lethalman to be potential reviewers. |
|
Yeah I think that would be useful as a general idea. There should be a way to say I am currently thinking in the same lines related to multi-arch binary releases. There should be a way to say |
|
So should we merge it and move all Go packages to use |
|
Sure! I'd be glad if we can benefit from unified NIXON format for fetchers. |
|
One possible implementation would be to do: [
{
goPackagePath = "github.com/Masterminds/vcs";
fetch = {
fetcher = "fetchFromGitHub";
owner = "Masterminds";
repo = "vcs";
rev = "fbe9fb6ad5b5f35b3e82a7c21123cfc526cbf895";
sha256 = "09rdq8k2smwgy6wdslddcq13wg3lzd4amzpy0f8kd0hlxxvas89c";
};
}
]And then in your code you could have a condition: if goDep.fetch ? fetcher then fetchdata goDep.fetch else ...and you can retain the other two branches for backward compatibility. I know the |
c45f8dd to
d05b21d
Compare
|
@disassembler This rebuilds nothing because it does not change any derivation. You should be able to see for yourself with |
|
Thanks for the tips! @orivej you think this is good to merge? With me fixing those changes, I don't feel like being the one to hit the button without another review! |
orivej
left a comment
There was a problem hiding this comment.
Let's wait another day for others to review, then I'd merge this.
|
Unlike [1] { fetch }: [
{
goPackagePath = "github.com/Masterminds/vcs";
src = fetch.github "Masterminds" "vcs" "v1.12.0" "09rdq8k2smwgy6wdslddcq13wg3lzd4amzpy0f8kd0hlxxvas89c" { };
}
{
goPackagePath = "github.com/jawher/mow.cli";
src = fetch.zip "https://github.com/jawher/mow.cli/archive/v1.0.3.zip" "1a8hnh2k3vc3prjhnz4rjbiwhqq6r3mi18h9cdb6fc6s6yzjc19j" { };
}
]because go2nix is generating fetchers with a fixed number of arguments, or even { fetch }: {
"github.com/Masterminds/vcs" = fetch.github "Masterminds" "vcs" "v1.12.0" "09rdq8k2smwgy6wdslddcq13wg3lzd4amzpy0f8kd0hlxxvas89c" { };
"github.com/jawher/mow.cli" = fetch.zip "https://github.com/jawher/mow.cli/archive/v1.0.3.zip" "1a8hnh2k3vc3prjhnz4rjbiwhqq6r3mi18h9cdb6fc6s6yzjc19j" { };
}if you don't expect the need for additional attributes. |
|
Eelco is against adding a generic fetcher to nixpkgs as far as I remember so we should avoid doing that. But we are still free to do what we want with the goDeps I believe. One important thing is that the generated code should be able to evolve independently from nixpkgs when people are using it outside of the repo. For that I think that we should at least introduce a top-level Regarding the exact schema, it will be easier to maintain it if we only have to deal with pure data and no functions as function have a tendency to change. Then in the goDeps loader we can implement and update the heuristic as needed when nixpkgs evolves. For the exact schema shape I would like to suggest looking at the generated lock files generated by tools like govendor and see if we can re-use any of it. Ideally we can read the govendor (or other) tool's lock file directly, that would be one less tool to maintain. |
|
OK, so It looks reasonable to use @zimbatm by adding top-level @orivej I think that your proposals needs a better design or a separate PR to see better what changes needs to be done in existing Go derivations. |
|
@kamilchm yes, the schemaVersion would be on the top of deps.nix and be bumped when backward-incompatible changes are introduced. |
|
OK, let's postpone schema changes and use what this PR makes available. |
Motivation for this change
It's more like a proposal than a real change.
I can convert all github
goDepsfromfetchgittofetchFromGitHubso they will look like:So let me know is it ok and after we merge
fetchFromGitHubsupport I'll convert allgoDepsthat can use it and addfetchFromGitHubtogo2nix.Things done
(nix.useSandbox on NixOS,
or option
build-use-sandboxinnix.confon non-NixOS)
nix-shell -p nox --run "nox-review wip"./result/bin/)CC: @copumpkin, @edolstra, @rushmorem, @zimbatm, @cstrahan
#16017 (comment)
#17254 (comment)