Skip to content

Commit

Permalink
go: use non-versioned buildGoModule to support out-of-band compilers
Browse files Browse the repository at this point in the history
If you set `languages.go.package` to a version of the go compiler that
doesn't yet exist in the `nixpkgs` input, you'll get an evaluation
error on `buildGoXXXModule` because the function for that specific
version doesn't exist.

I couldn't find anything in the docs preventing us from using the base
`buildGoModule` and override the `go` argument as we already do.
  • Loading branch information
sandydoo committed Nov 3, 2024
1 parent 5c046ee commit f7ab477
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/modules/languages/go.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@
let
cfg = config.languages.go;

goVersion = (lib.versions.major cfg.package.version) + (lib.versions.minor cfg.package.version);

buildWithSpecificGo = pkg: pkg.override {
buildGoModule = pkgs."buildGo${goVersion}Module".override {
go = cfg.package;
};
};
# Override the buildGoModule function to use the specified Go package.
buildGoModule = pkgs.buildGoModule.override { go = cfg.package; };
buildWithSpecificGo = pkg: pkg.override { inherit buildGoModule; };
in
{
options.languages.go = {
Expand Down Expand Up @@ -45,7 +41,7 @@ in
(buildWithSpecificGo pkgs.gotests)
];

hardeningDisable = (lib.optional (cfg.enableHardeningWorkaround) "fortify");
hardeningDisable = lib.optional (cfg.enableHardeningWorkaround) "fortify";

env.GOROOT = cfg.package + "/share/go/";
env.GOPATH = config.env.DEVENV_STATE + "/go";
Expand Down

0 comments on commit f7ab477

Please sign in to comment.