I was finally able to make even the original untouched main branch to work by looking again on the sops/package.nix file in nixpkgs.
It contained:
postPatch = ''
substituteInPlace go.mod \
--replace-fail "go 1.22" "go 1.22.7"
'';
And now overriding golang to 1.23.0 and using that I was able to make it compile:
nix-build --expr 'with (import <nixpkgs> { });
(sops.override {
buildGo122Module = args: buildGo123Module ( args // { vendorHash = "sha256-anKhfq3bIV27r/AvvhSSniKUf72gklv8waqRz0lKypQ="; });
}).overrideAttrs {
src = fetchFromGitHub {
owner = "getsops";
repo = "sops";
rev = "2eb776b01df5df04eee626da3e99e9717fffd9e0";
hash = "sha256-VB4/DyQoQnV/AAXteJPsD2vbtAilZcJPTCXk2nvUZU8=";
};
postPatch = \'\'
substituteInPlace go.mod \
--replace-fail "go 1.22" "go 1.23.0"
\'\';
}'
Seems interesting that the postPatch step worked but running go tidy mod in the preBuild step did not.