-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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
Undocumented / impossible: override go modules #86349
Comments
I have the same issue, unfortunately, and I have not been able to look into it. |
@doronbehar this worked for me
|
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? |
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 Then I suppose in the same way as there is |
I think we should strive to have less of such functions with different names but the same meaning. |
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 #86349 (comment) worked for me (replacing {
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 Also Go 1.17 is already out, and |
It now requires esbuild, which wants to download stuff as part of install script. Fortunately, it can be bypassed by an environment variable. evanw/esbuild#881 Also, annoyingly, Nixpkgs’s Go infrastructure does not support overriding attributes of buildGoPackage: NixOS/nixpkgs#86349
Original Comment
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 Tailscale
|
Inline geth nix derivation in repo and use submodule for code We can't simply override the `src` attribute of the go-ethereum derivation because this doesn't work with vendored go dependencies. For more info: NixOS/nixpkgs#86349 . Here we copy the nix derivation from nixpkgs to ./nix/go-ethereum folder of this repo. Nix will print a mismatch to the console if the vendored geth dependencies change. In that case the new vendorSha256 in the inlined geth nix derivation in ./nix/go-ethereum/ needs to be updated. This is a stop-gap solution so we can all work with the same version of geth until we find a better way to enable that.
In #158486, I work around this issue by passing related attributes including 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? :)
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 |
overrideAttrs does not combine well with buildGoModule (see NixOS/nixpkgs#86349 for details), so I went with a simple approach of defining a new derivation instead.
* this is a terrible hack but unfortunately it's necessary because buildGoModule computes the vendorHash after installing all Go modules * although overriding the vendorHash works just fine, there's still something wrong because the overlay is not applied properly, as per kluctl --version kluctl version v2.22.1 Resolves: Related: NixOS/nixpkgs#86349 Signed-off-by: Daniel-Andrei Minca <[email protected]>
Closing as this is fixed since #225051 is merged. |
* this is a terrible hack but unfortunately it's necessary because buildGoModule computes the vendorHash after installing all Go modules * although overriding the vendorHash works just fine, there's still something wrong because the overlay is not applied properly, as per kluctl --version kluctl version v2.22.1 Resolves: Related: NixOS/nixpkgs#86349 Signed-off-by: Daniel-Andrei Minca <[email protected]>
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 (#85452), due to an unresolved issue with the version build flags :(.
Notify maintainers
@kalbasit ? As the author of
buildGoModule
according to git blame...The text was updated successfully, but these errors were encountered: