Open doronbehar opened 4 years ago
I have the same issue, unfortunately, and I have not been able to look into it.
@doronbehar this worked for me
(self: super: {
bazel-gazelle = (super.callPackage "${super.path}/pkgs/development/tools/bazel-gazelle" {
buildGoModule = args: super.buildGoModule (args // {
modSha256 = "13yx70p0x7hpdp2zn7zrl0i88fk6dhcryp0lmn0zwdn92ldm3n5y";
patches = (args.patches or []) ++ super.lib.lists.singleton (super.fetchpatch {
url = "https://github.com/bazelbuild/bazel-gazelle/pull/749.patch";
sha256 = "03sxbgwvb6hxwpmk9mckwjzgxank9difc0bgvzl6x3rir76ivwmj";
});
});
});
})
Damn you are overriding the goddamn function. It's nice to know this is not "Impossible". Do you think @kalbasit this interface could be improved somehow?
@kalbasit I've stumbled upon another point to improve the golang docs at https://github.com/NixOS/nixpkgs/pull/97856 . I'm not sure whether this should be documented or not along with the other changes - overrideModAttrs
doesn't seem to be able to provide what it promises.
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/inconsistent-vendoring-in-buildgomodule-when-overriding-source/9225/4
The problem with pythonBuildPackage described at https://discourse.nixos.org/t/un-disabling-a-python-package-in-an-overlay/10593 seems similar to me. Perhaps overrideAttrs documentation should be improved to better explain those traps.
I've also stumbled on this when trying to override some go package which involved changing vendorSha256
too.
So if I understood this correctly the problem with overrideAttrs
is that it works just with a simple mkDerivation
, but buildGoModule
internally does more and calls mkDerivation
also for the vendored dependencies?
Then I suppose in the same way as there is overridePythonAttrs
there should be some overrideGoAttrs
.
Then I suppose in the same way as there is
overridePythonAttrs
there should be someoverrideGoAttrs
.
I think we should strive to have less of such functions with different names but the same meaning.
This one is a bit shorter:
(pkgs.istioctl.overrideAttrs (old: let
version = "1.7.1";
src = pkgs.fetchFromGitHub {
owner = "istio";
repo = "istio";
rev = version;
sha256 = "sha256-CvYqYxb19lSc61SrvGcf/kG9e9zosHz4JbByA+bN600=";
};
in rec {
name = "istioct-${version}";
inherit src;
go-modules = (pkgs.buildGoModule {
inherit name src;
vendorSha256 = "sha256-4Z4Fgv9zmAwp3tEvHj8yLOWkFY/zFz5VfehSWCuIUcI=";
}).go-modules;
}))
This one is a bit shorter:
@Mic92 this doesn't work for me, trying with:
{
kopia_unstable = nixos-2105.kopia.overrideAttrs (old:
let
version = "ede09c15854ce74fde40603a6857ed3991ba666c";
src = nixos-2105.fetchFromGitHub {
owner = "kopia";
repo = "kopia";
rev = version;
sha256 = "0wdkwpsgmycbiq8dvng3d0ps5qp87b7k1xvw8rv2wk1qzrrp6d93";
};
in
rec {
name = "kopia-${version}";
inherit src;
go-modules = (nixos-2105.buildGoModule {
inherit name src;
vendorSha256 = "1idg6l9cnii6694kdmv9sc42c0bzk7pk67sdlglkaz52kg5hc6bd";
}).go-modules;
});
}
Error output:
The approach from https://github.com/NixOS/nixpkgs/issues/86349#issuecomment-624489806 worked for me (replacing modSha256
by its successor vendorSha256
):
{
kopia_unstable =
let
version = "ede09c15854ce74fde40603a6857ed3991ba666c";
src = nixos-2105.fetchFromGitHub {
owner = "kopia";
repo = "kopia";
rev = version;
sha256 = "0wdkwpsgmycbiq8dvng3d0ps5qp87b7k1xvw8rv2wk1qzrrp6d93";
};
in
(nixos-2105.callPackage "${nixos-2105.path}/pkgs/tools/backup/kopia" {
buildGoModule = args: nixos-2105.buildGoModule (args // {
vendorSha256 = "1idg6l9cnii6694kdmv9sc42c0bzk7pk67sdlglkaz52kg5hc6bd";
inherit src version;
});
});
}
The approach from #86349 (comment) worked for me (replacing
modSha256
by its successorvendorSha256
):{ kopia_unstable = let version = "ede09c15854ce74fde40603a6857ed3991ba666c"; src = nixos-2105.fetchFromGitHub { owner = "kopia"; repo = "kopia"; rev = version; sha256 = "0wdkwpsgmycbiq8dvng3d0ps5qp87b7k1xvw8rv2wk1qzrrp6d93"; }; in (nixos-2105.callPackage "${nixos-2105.path}/pkgs/tools/backup/kopia" { buildGoModule = args: nixos-2105.buildGoModule (args // { vendorSha256 = "1idg6l9cnii6694kdmv9sc42c0bzk7pk67sdlglkaz52kg5hc6bd"; inherit src version; }); }); }
What about using nixos-2105.kopia.override
instead of nixos-2105.callPackage "${nixos-2105.path}/pkgs/tools/backup/kopia"
? This works when Nix is in restricted mode (in my case I was using flake).
Also Go 1.17 is already out, and latest
Tailscale requires it so it makes sense to use buildGoModule = args: (nixos-2105.buildGoModules.override { go = go_1_17; }) (args // { ... });
(waiting https://github.com/NixOS/nixpkgs/pull/127519 to merge, so we can ditch overriding Go in the first place)
Stumbled across this comment after realizing I couldn't build tailscale, but before I realized that's what this comment was about (tailscale specifically)😂
Seems to work fine with override
, and no wonder it was failing to build until I overrode the go
version used.
1.16.0
OverrideThanks for the pointer on overriding go
in buildGoModule
, I had not dug into Tailscale changes that far and did not realize a new Go version was required 🤪
In #158486, I work around this issue by passing related attributes including veniorSha256
as inputs, so that they can be owerrided with the override
attribute of the resulted package. An example can be found here:
Nevertheless, I still hope that this issue can be fixed. If not, we should at least document the workaround.
Overlay-style overridable mkDerivation (#119942) might be one of the ultimate solutions to issues of this kind. See #171586.
@Mic92 Do you have a complete example for those of us who are still learning the language? :)
zabbix-overlay =
(self: super: super.zabbix.agent2.overrideAttrs (
let
version = "5.4.11";
src = super.fetchurl {
url = "https://cdn.zabbix.com/zabbix/sources/oldstable/5.4/zabbix-5.4.11.tar.gz";
sha256 = "sha256-mxEsUFlnDB8MHWX6zWZaETNzNW6ut9ro28hXGG490kQ=";
};
in
rec {
name = "zabbix.agent2";
inherit src;
go-modules = (self.buildGoModule {
inherit name src;
vendorSha256 = "sha256-4Z4Fgv9zmAwp3tEvHj8yLOWkFY/zFz5VfehSWCuIUcI=";
}).go-modules;
}
)
);
I'm getting an infinite loop here.
@Mic92 Do you have a complete example for those of us who are still learning the language? :)
zabbix-overlay = (self: super: super.zabbix.agent2.overrideAttrs ( let version = "5.4.11"; src = super.fetchurl { url = "https://cdn.zabbix.com/zabbix/sources/oldstable/5.4/zabbix-5.4.11.tar.gz"; sha256 = "sha256-mxEsUFlnDB8MHWX6zWZaETNzNW6ut9ro28hXGG490kQ="; }; in rec { name = "zabbix.agent2"; inherit src; go-modules = (self.buildGoModule { inherit name src; vendorSha256 = "sha256-4Z4Fgv9zmAwp3tEvHj8yLOWkFY/zFz5VfehSWCuIUcI="; }).go-modules; } ) );
I'm getting an infinite loop here.
Try packageOverrides instead to avoid infinite recursions due the overlay.
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/inconsistent-vendoring-in-buildgomodule-when-overriding-source/9225/7
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/use-a-specific-version-of-terraform-in-a-nix-shell/27880/1
Describe the bug
I'm trying to write an overlay that will override attributes of a package that is built with
buildGoModule
and I'm having trouble overriding the modules derivation of it.It seems the author's intention was that I'd use
overrideModAttrs
as an argument tobuildGoModule
? But I guess this doesn't work with overlays? Whatever I do, I get either an evaluation error or a build error because the oldgo-modules
is used. Here are a few examples I tried:But the build still took the old go modules derivation.
I also tried instead:
Which failed with:
And I even went as far as:
But that also failed because the build used the old go-modules. I can confirm though, that it did override the
configurePhase
which is the only place${go-modules}
is evaluated.Expected behavior
It shouldn't be that difficult to override a go modules derivation.
Screenshots If applicable, add screenshots to help explain your problem.
Additional context
I'm trying to override a package I maintain which it's update is stale (https://github.com/NixOS/nixpkgs/pull/85452), due to an unresolved issue with the version build flags :(.
Notify maintainers
@kalbasit ? As the author of
buildGoModule
according to git blame...