Skip to content
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

golangci-lint: build with buildGo123Module #339057

Merged
merged 1 commit into from
Sep 3, 2024
Merged

Conversation

budimanjojo
Copy link
Contributor

@budimanjojo budimanjojo commented Sep 2, 2024

Description of changes

Build golangci-lint with go_1_23.

Currently, the golangci-lint refuses to run when the project is using higher Go version than the version used to build the program (see golangci/golangci-lint#4938).
This was because of a severe memory leak issue when trying to run golangci-lint on go 1.23 project.

There's no point of still building it with older version of Go since golangci-lint already support it since 1.60.1.

Before this change:

 golangci-lint --version
golangci-lint has version 1.60.3 built with go1.22.6 from v1.60.3 on 19700101-00:00:00

After this change:

 ./result/bin/golangci-lint --version
golangci-lint has version 1.60.3 built with go1.23.0 from v1.60.3 on 19700101-00:00:00

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

Signed-off-by: budimanjojo <budimanjojo@gmail.com>
@budimanjojo
Copy link
Contributor Author

Tagging @SuperSandro2000 and @Mic92 as the maintainer of the package

@budimanjojo
Copy link
Contributor Author

Not sure why the CI failed, the log looks unrelated to this PR too.

@Mic92
Copy link
Member

Mic92 commented Sep 3, 2024

@ofborg eval

@@ -1,6 +1,6 @@
{ buildGoModule, fetchFromGitHub, lib, installShellFiles }:
{ buildGo123Module, fetchFromGitHub, lib, installShellFiles }:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any other projects that are affected by this in the same way?
A buildGoModule_latest would be useful in that instance.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think gopls is another one that wants latest available Go as much as possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also think we should always use latest available go to build packages, so maybe default buildGoModule to latest version, and for packages that don't like it can use something like buildGoModule_stable or the currently available buildGo122Module?

Copy link
Member

@Mic92 Mic92 Sep 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That could delay adding new go compilers significantly because now go release maintainers have to upgrade the ecosystem in one go. In the end you would be in a worse position for your projects because there would be no new go compiler to switch to in nixpkgs until everything is updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay, I don't really understand how things work in nixpkgs tbh so you might have the better answer than me. For now the most important thing for me is golangci-lint and gopls because it has a really nasty habit of freezing my system with all RAM and CPU maxed out whenever I open my LSP enabled Neovim on a project with latest go.mod file so I think these two should always use latest available Go version when possible.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

govulncheck too 🙏

@Mic92 Mic92 merged commit 74a18ff into NixOS:master Sep 3, 2024
29 of 31 checks passed
@budimanjojo budimanjojo deleted the golangci branch September 3, 2024 07:08
@@ -1,6 +1,6 @@
{ buildGoModule, fetchFromGitHub, lib, installShellFiles }:
{ buildGo123Module, fetchFromGitHub, lib, installShellFiles }:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

such overrides should be done in all-packages.nix

/~https://github.com/NixOS/nixpkgs/tree/master/pkgs/by-name#changing-implicit-attribute-defaults

i know these docs are for by-name, but same argument applies

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this doesn't really matter

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in my local project, I override buildGoModule for gopls, golangcl-lint and few others, each time I update nixpkgs, I have to fix arguments, because callPackage augments keep changing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually @kirillrdy is kinda right. Right now I have this in my overlay:

(final:prev: {
  gopls = prev.gopls.override { buildGoModule = prev.buildGo123Module; };
})

If this got into unstable, then my override will not work anymore. But I also think that if it's done in all-packages.nix, it will be hard to find out which go version is being used because all-packages.nix is so hard to look at in browser because of the file size.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having buildGoModule_latest or some sort like suggested by @Mic92 is the way to go IMO.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Afaik go has a principle of backward compatibility and using latest go version to build packages should do no harm? Maybe I'm wrong but I never have issue building ancient packages using latest go version.

Also, we have full control on when to bump buildGoModule_latest up not necessarily on day one of new go release?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For normal packages yes, go is backwards compatible, but packages that deeply go into the compile process like linters may compile but sometimes don't properly work and need a fix because some internal changed.

Also if we need to wait for a few days and updates to some packages, the point of a buildGoModule_latest twingles.

Copy link
Member

@maxbrunet maxbrunet Sep 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about something like that?

Suggested change
{ buildGo123Module, fetchFromGitHub, lib, installShellFiles }:
{ buildGo123Module
, fetchFromGitHub
, lib
, installShellFiles
, builder ? buildGo123Module
}:

and then users can override builder (or whatever we decide to name it) without worrying about it being renamed and everything remain in this file:

(final:prev: {
  golangci-lint = prev.golangci-lint.override { builder = prev.buildGo124Module; };
})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be lots of different ways to achieve this! I want to submit a pr to do the same for govulncheck to build it with latest go for the same reason as this pr, but I'm not sure which option to choose.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maxbrunet that is equal to overriding buildGoModule in all-packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants