fix cross compiling

select go compiler in `buildPackages` instead of `pkgs`
This commit is contained in:
HuangYi 2023-02-15 14:31:29 +08:00
parent 89cd0675b9
commit 72890726f3
No known key found for this signature in database
GPG key ID: 58776091521E8B17

View file

@ -8,6 +8,7 @@
, cacert
, pkgs
, pkgsBuildBuild
, buildPackages
, runtimeShell
, writeScript
, gomod2nix
@ -127,20 +128,20 @@ let
);
# Return a Go attribute and error out if the Go version is older than was specified in go.mod.
selectGo = attrs: goMod: attrs.go or (if goMod == null then pkgs.go else
selectGo = attrs: goMod: attrs.go or (if goMod == null then buildPackages.go else
(
let
goVersion = goMod.go;
goAttrs = lib.reverseList (builtins.filter
(
attr: lib.hasPrefix "go_" attr && lib.versionAtLeast pkgs.${attr}.version goVersion
attr: lib.hasPrefix "go_" attr && lib.versionAtLeast buildPackages.${attr}.version goVersion
)
(lib.attrNames pkgs));
(lib.attrNames buildPackages));
goAttr = elemAt goAttrs 0;
in
(
if goAttrs != [ ]
then pkgs.${goAttr}
then buildPackages.${goAttr}
else throw "go.mod specified Go version ${goVersion}, but no compatible Go attribute could be found."
)
));