Skip to content

Commit f7ab477

Browse files
committed
go: use non-versioned buildGoModule to support out-of-band compilers
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.
1 parent 5c046ee commit f7ab477

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/modules/languages/go.nix

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,9 @@
33
let
44
cfg = config.languages.go;
55

6-
goVersion = (lib.versions.major cfg.package.version) + (lib.versions.minor cfg.package.version);
7-
8-
buildWithSpecificGo = pkg: pkg.override {
9-
buildGoModule = pkgs."buildGo${goVersion}Module".override {
10-
go = cfg.package;
11-
};
12-
};
6+
# Override the buildGoModule function to use the specified Go package.
7+
buildGoModule = pkgs.buildGoModule.override { go = cfg.package; };
8+
buildWithSpecificGo = pkg: pkg.override { inherit buildGoModule; };
139
in
1410
{
1511
options.languages.go = {
@@ -45,7 +41,7 @@ in
4541
(buildWithSpecificGo pkgs.gotests)
4642
];
4743

48-
hardeningDisable = (lib.optional (cfg.enableHardeningWorkaround) "fortify");
44+
hardeningDisable = lib.optional (cfg.enableHardeningWorkaround) "fortify";
4945

5046
env.GOROOT = cfg.package + "/share/go/";
5147
env.GOPATH = config.env.DEVENV_STATE + "/go";

0 commit comments

Comments
 (0)