|
9 | 9 | if len == 0 then [ ] else final.lib.lists.take (len - 1) l ++ [ newVal ]; |
10 | 10 | in |
11 | 11 | { |
| 12 | + # Provide threads compatibility for MinGW cross-compilation |
| 13 | + # In newer nixpkgs, targetPackages.threads is not available, but go_1_24 expects it |
| 14 | + threads = super.threads or (if final.stdenv.hostPlatform.isWindows then { |
| 15 | + package = final.windows.pthreads; |
| 16 | + } else null); |
| 17 | + |
12 | 18 | # Override go_1_24 to create go_1_25 with Windows platform support |
13 | 19 | # Native nixpkgs go_1_25 doesn't support Windows (x86_64-windows not in meta.platforms) |
14 | 20 | # By overriding go_1_24, we inherit its Windows support |
15 | 21 | # See: https://github.com/crypto-org-chain/chain-main/pull/1220 |
16 | | - go_1_25 = super.go_1_24.overrideAttrs (old: rec { |
| 22 | + go_1_25 = super.go_1_24.overrideAttrs (old: |
| 23 | + let |
| 24 | + # For MinGW cross-compilation, we need pthreads from the target (Windows) platform |
| 25 | + # The old go_1_24 expects targetPackages.threads.package which doesn't exist in newer nixpkgs |
| 26 | + # So we manually provide it here |
| 27 | + windowsPthreads = if final.stdenv.hostPlatform.isWindows then final.windows.pthreads else null; |
| 28 | + in rec { |
17 | 29 | version = "1.25.0"; |
18 | 30 | src = final.fetchurl { |
19 | 31 | url = "https://go.dev/dl/go${version}.src.tar.gz"; |
20 | 32 | hash = "sha256-S9AekSlyB7+kUOpA1NWpOxtTGl5DhHOyoG4Y4HciciU="; |
21 | 33 | }; |
22 | | - # Filter out patches that don't apply to Go 1.25 |
23 | | - patches = builtins.filter ( |
24 | | - patch: |
25 | | - let |
26 | | - name = builtins.baseNameOf (builtins.toString patch); |
27 | | - in |
28 | | - !(final.lib.hasSuffix "iana-etc-1.17.patch" name) |
29 | | - ) (old.patches or [ ]); |
30 | | - # Apply the iana-etc substitutions manually for Go 1.25 |
31 | | - postPatch = (old.postPatch or "") + '' |
32 | | - substituteInPlace src/net/lookup_unix.go \ |
33 | | - --replace 'open("/etc/protocols")' 'open("${final.iana-etc}/etc/protocols")' |
34 | | - substituteInPlace src/net/port_unix.go \ |
35 | | - --replace 'open("/etc/services")' 'open("${final.iana-etc}/etc/services")' |
36 | | - ''; |
| 34 | + # Directly set depsTargetTarget instead of relying on the old value |
| 35 | + # For MinGW targets, we need the pthreads library |
| 36 | + depsTargetTarget = final.lib.optional final.stdenv.targetPlatform.isMinGW windowsPthreads; |
| 37 | + # For Windows cross-compilation, we need to completely avoid the iana-etc patch |
| 38 | + # as it creates a dependency on iana-etc which isn't available for Windows |
| 39 | + # For other platforms, filter out patches that don't apply to Go 1.25 |
| 40 | + patches = if final.stdenv.targetPlatform.isWindows then |
| 41 | + # On Windows, use an empty patch list to avoid iana-etc dependency |
| 42 | + [] |
| 43 | + else |
| 44 | + # On Unix-like systems, filter patches as before |
| 45 | + builtins.filter ( |
| 46 | + patch: |
| 47 | + let |
| 48 | + name = builtins.baseNameOf (builtins.toString patch); |
| 49 | + in |
| 50 | + !(final.lib.hasSuffix "iana-etc-1.17.patch" name) |
| 51 | + ) (old.patches or [ ]); |
| 52 | + # Don't inherit postPatch from go_1_24 as it may contain iana-etc dependencies |
| 53 | + # Go 1.25 source code doesn't need the same patches as Go 1.24 |
| 54 | + # If needed, we can add Go 1.25-specific patches here |
| 55 | + postPatch = ""; |
| 56 | + # Explicitly add Windows platform support (x86_64-windows, i686-windows) |
| 57 | + # Go 1.24 supports Windows but Go 1.25 upstream doesn't include it in meta.platforms |
| 58 | + meta = old.meta // { |
| 59 | + platforms = (old.meta.platforms or [ ]) ++ final.lib.platforms.windows; |
| 60 | + }; |
37 | 61 | }); |
38 | 62 | rocksdb = final.callPackage ./rocksdb.nix { }; |
39 | 63 | golangci-lint = final.callPackage ./golangci-lint.nix { }; |
|
0 commit comments