File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change 5
5
6
6
# Override the buildGoModule function to use the specified Go package.
7
7
buildGoModule = pkgs . buildGoModule . override { go = cfg . package ; } ;
8
+ # A helper function to rebuild a package with the specific Go version.
9
+ # It expects the package to have a `buildGo*Module` argument in its override function.
10
+ # This will override multiple buildGo*Module arguments if they exist.
8
11
buildWithSpecificGo = pkg :
9
12
let
10
13
overrideArgs = lib . functionArgs pkg . override ;
14
+ goModuleArgs = lib . filterAttrs ( name : _ : lib . match "buildGo.*Module" name != null ) overrideArgs ;
15
+ goModuleOverrides = lib . mapAttrs ( _ : _ : buildGoModule ) goModuleArgs ;
11
16
in
12
- if builtins . hasAttr "buildGoModule" overrideArgs then
13
- pkg . override { inherit buildGoModule ; }
14
- else if builtins . hasAttr "buildGoLatestModule" overrideArgs then
15
- pkg . override { buildGoLatestModule = buildGoModule ; }
17
+ if goModuleOverrides != { } then
18
+ pkg . override goModuleOverrides
16
19
else
17
- throw "Package ${ pkg . pname or "unknown" } does not accept buildGoModule or buildGoLatestModule arguments" ;
20
+ throw ''
21
+ `languages.go` failed to override the Go version for ${ pkg . pname or "unknown" } .
22
+ Expected to find a `buildGo*Module` argument in its override function.
23
+
24
+ Found: ${ toString ( lib . attrNames overrideArgs ) }
25
+ '' ;
18
26
in
19
27
{
20
28
options . languages . go = {
You can’t perform that action at this time.
0 commit comments