-
-
Notifications
You must be signed in to change notification settings - Fork 13.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gomod2nix: init at 1.5.0 #188272
gomod2nix: init at 1.5.0 #188272
Conversation
Repating myself from: #188035 (comment)
|
The update script seems broken, doesn't seem to eval. I said previously I won't block on this so if you just want to drop it from this PR and deal with it in a follow up I'm fine with that. Can you share your plans and time frame for promoting for this? |
b43e169
to
c2049d5
Compare
I made a fix to make the updater work in the case that
I have patches ready for all the Go packages I maintain in nixpkgs and will announce the availability of gomod2nix in nixpkgs shortly after at least a few of those have been merged. Additionally I also have patches for most of the packages that still use vgo2nix ready too, it's just blocked on this PR. |
@zowoq FYI the upstream repo has been moved to nix-community. |
I think the case-sensitive problems in #129730 may also be a problem for this?
Sorry, still doesn't seem to work. Can you add an example to this PR?
Not any of the podman packages please.
Can we wait at least a couple weeks on this? I'd like to do some testing and fix some nits first. I really don't see why this needs to be rushed, at one point I thought the upstream project had been abandoned. IIRC the go no vendor patch was added 18 months ago.
Cool, thanks. |
Sure that could wait, no problem.
I was talking about the ones where I'm the sole maintainer,.
I don't think so, I could add a test case for it though.
Sure, I've added repackaged a fairly low impact package in this PR. |
@@ -0,0 +1,167 @@ | |||
schema = 3 | |||
subPackages = ["cmd/trillian_log_server", "cmd/trillian_log_signer", "cmd/createtree", "cmd/deletetree", "cmd/updatetree"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this need to be moved?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not moved per se, you can still set the same attribute in the Nix expression.
This is just another way to set the same thing which is a lot easier to control from the code generator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but why do we need to pass this through the code generator? This often needs to be modify to build additional tools or not build testing tools. For me this belongs into the nix-expression and not in the generated code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For one it serves to reduce the build time closure size.
We don't actually need everything in the root level go.mod and by making the generator aware of what needs to be built we only need to pull in the actually required subset of dependencies.
subPackages = ["cmd/trillian_log_server", "cmd/trillian_log_signer", "cmd/createtree", "cmd/deletetree", "cmd/updatetree"] | ||
goPackagePath = "github.com/google/trillian" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Why is this needed?
- Why can't we infer this from the
src
? - Why does it need to be in this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no src
attribute explicitly being set.
The goPackagePath
is there so the derivation knows which sources to select for the src
attribute.
You could separate the src
if you wanted to and do the whole manual hash update dance, nothing stops you from doing that but that will leave you without an update script.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no
src
attribute explicitly being set.
I am not really a fan of this. If I want to access the source files nix is building things from to investigate and debug packages I often use nix build .#name.src
and I would tell people to do that when debugging. Could we add it at least as an alias back to make things more uniform with other packages?
Also we need to make sure that it is clear in the documentation that goPackagePath
here has nothing to do with buildGoPackage.
BTW what is your plan for documentation?
oh the whole thing gets stuffed into the toml. src, version and everything. TBH I really don't like this:
|
You could rewrite it in a more verbose way if you wanted to. Look at how https://github.com/nix-community/gomod2nix/blob/master/generic.nix or https://github.com/crypto-org-chain/chain-main/blob/master/default.nix are constructed for example. There are very good reasons to do it this way though. In Otherwise we'd have a similarly bad user experience once again for very little reason. |
To get the package version I either need to query the package via nix or grep the toml? |
In this instance, yes. |
Sorry but I think burying the version in the toml is absolutely horrible. |
Ok, I don't see the problem. There is plenty of prior art in nixpkgs already. |
Both. Ruby packages comes to mind.
Would you feel better if we also stuck the version attribute in the top-level attributes in the toml file? |
If you mean
Only marginally. Would need to be enforced, I really don't want debates over it and packages flipping back and forth between (buried in toml|top of toml|set in default.nix).
I'm kinda worried about the fact that this is possible. At the moment there is (basically) one way of writing a go package, this seems to allow a lot more variation (and more debates). Consistency is good UX also. |
Carnix is another one (code generator), so is poetry2nix (reads pyproject.toml). I think it's disingenuous to say that Emacs is easier to inspect visually, the majority of that lives in massive auto generated files. The same goes for Haskell, Node & many more. My take is that this whole version in the nix file or not comment is just bike shedding with extremely small practical impact.
Which is intentional. The needs of a packager packaging up an application in a private repo has somewhat different concerns than someone packaging something that is developed entirely outside of the package tree.
|
Not familiar with these but at a glance they both seem pretty close to a standard package?
They all seem to declare a version that isn't mixed in with it's own deps?
I'll response to these all at once as it's basically the same point: Yeah, I agree that buildGoModule isn't fit for dev use outside of nixpkgs and yes, I agree that different packagers have different needs. For packages that are in nixpkgs we don't need (and IMO really don't want) a more complex tool that can be used in multiple ways/styles. We have ~1200 Just to be clear: I'm not objecting to using |
Did you do some testing with big go.mod files and how they behave like https://github.com/golangci/golangci-lint/blob/master/go.mod and more complex ones like https://github.com/open-policy-agent/gatekeeper/blob/master/go.mod ? Also what if the project uses replace where we can't use |
same for me. This is not very great from a reviewers perspective who needs to double check that people did not forgot to update version or some hash. |
Glad to see a solution without |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am sorry that we are doing another review round but I'd rather do this correct the first time than fixing it up multiple times and potentially breaking already packaged packages with it.
…ore readable Implement suggestion from NixOS/nixpkgs#188272 (comment).
d257851
to
06e13d1
Compare
06e13d1
to
b83aa88
Compare
b83aa88
to
a69d230
Compare
Trying this again: If there is nothing new and actionable by Friday (2022-09-09) I will merge this. |
You haven’t responded to a few concerns from Sandro and myself. Between us we’ve done the majority of the go maintenance for the last year so I don’t think our concerns should be dismissed.
I don’t think this has been addressed?
Renaming
I don’t mind if this PR is merged without docs but I think having docs is a blocker for
This hasn’t been addressed. As you asked for something actionable: I’d like to see the src/hash/version not treated as just another dep and be moved to the top of the toml with the other attributes. I consider this a blocker for merging this PR.
Sandro's asked about this twice (in this PR and #188035 (comment)) and there doesn't seem to have been a response? |
As someone who's also been packaging go modules a bunch I agree with all @zowoq & @SuperSandro2000 's points in that comment I'll try this out with cosign which has a bajillion dependencies |
symlink = mkInternalPkg "symlink" ./symlink/symlink.go; | ||
|
||
# Install development dependencies from tools.go | ||
install = mkInternalPkg "symlink" ./install/install.go; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
install = mkInternalPkg "symlink" ./install/install.go; | |
install = mkInternalPkg "install" ./install/install.go; |
"strconv" | ||
) | ||
|
||
const filename = "tools.go" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it actually enforced that the file is called tools.go
or just that the build tag is tools
?
https://marcofranssen.nl/manage-go-tools-via-go-modules
// +build tools
I can't really find any docs on this
Description of changes
This adds gomod2nix, a generator for Nix expressions using Go modules (and the associated build infrastructure).
It has quite some differences to
buildGoModule
which are laid out in https://www.tweag.io/blog/2021-03-04-gomod2nix/.I don't feel quite ready yet to promote
buildGoApplication
andmkGoEnv
to first-class top-level attributes so in nixpkgs these will be accessed bygomod2nix.buildGoApplication
&gomod2nix.mkGoEnv
respectively.This is developed external over at https://github.com/tweag/gomod2nix/.
This work has been sponsored by both the NLNet Foundation under the NGI Zero program and by Tweag.
Due to a mistake this is a new instance of #188035. See that PR for previous discussion.
Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)nixos/doc/manual/md-to-db.sh
to update generated release notes