Skip to content

Conversation

onnimonni
Copy link

@onnimonni onnimonni commented Mar 19, 2025

Hey,

Because the go.mod file is not up to date different upstream packaging software need to rely on weird hacks to build from main branch.

For example if you look homebrew they by default always need to run:

$ go mod tidy

Because of this I'm also not able to build the current master with nix as seen in this pretty long thread in nix forums.

Would it be possible to update this?

Signed-off-by: Onni Hakala <onni@flaky.build>
@onnimonni
Copy link
Author

onnimonni commented Mar 19, 2025

If I try to use the same go version as in go.mod I get this::

$ nix-build --expr 'with (import <nixpkgs> { });
                                   (sops.override {
                                     buildGo122Module = args: buildGo122Module ( args // { vendorHash = "sha256-anKhfq3bIV27r/AvvhSSniKUf72gklv8waqRz0lKypQ="; });
                                   }).overrideAttrs {
                                     src = fetchFromGitHub {
                                       owner = "getsops";
                                       repo = "sops";
                                       rev = "2eb776b01df5df04eee626da3e99e9717fffd9e0";
                                       hash = "sha256-VB4/DyQoQnV/AAXteJPsD2vbtAilZcJPTCXk2nvUZU8=";
                                     };
                                   }'

...

> go: cloud.google.com/go in vendor/modules.txt requires go >= 1.23.0 (running go 1.22.12; GOTOOLCHAIN=local)

And If I try to use go version 1.23:

nix-build --expr 'with (import <nixpkgs> { });
(sops.override {
  buildGo122Module = args: buildGo123Module ( args // { vendorHash = ""; });
}).overrideAttrs {
  src = fetchFromGitHub {
    owner = "getsops";
    repo = "sops";
    rev = "2eb776b01df5df04eee626da3e99e9717fffd9e0";
    hash = "sha256-VB4/DyQoQnV/AAXteJPsD2vbtAilZcJPTCXk2nvUZU8=";
  };
}'

I get:

go: updates to go.mod needed; to update it:
        go mod tidy

Copy link
Contributor

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

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

We use go 1.22 and 1.23 in CI, so 1.22 has to stay in there.

In any case, I can build sops fine locally with go 1.24 without this change (once vendoring is done).

@felixfontein
Copy link
Contributor

CC @getsops/maintainers since others know more about Go packaging than me...

@onnimonni
Copy link
Author

Sorry I'm not familiar but I would want to learn. What do you mean when you say?

(once vendoring is done).

I noticed that even the latest sops release in nixpkgs needs to patch the go.mod file to get it compiling:

postPatch = ''
    substituteInPlace go.mod \
      --replace-fail "go 1.22" "go 1.22.7"
  '';

And they are using go 1.22 in the builds.

@felixfontein
Copy link
Contributor

To build it locally, I usually run make vendor (which runs go mod tidy and go mod vendor), then undo the changes to go.mod to get rid of the bumped Go version, and then make install (which runs go install github.com/getsops/sops/v3/cmd/sops). (When using the Makefile, GOPROXY=https://proxy.golang.org is set for all three calls, if that is of any relevance.)

@felixfontein
Copy link
Contributor

Closing since no longer needed due to #1819. Thanks for your contribution!

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

Successfully merging this pull request may close these issues.

2 participants