Skip to content

Commit f42e703

Browse files
committed
update nix
1 parent d78ab09 commit f42e703

File tree

3 files changed

+47
-18
lines changed

3 files changed

+47
-18
lines changed

nix/build_overlay.nix

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,55 @@ let
99
if len == 0 then [ ] else final.lib.lists.take (len - 1) l ++ [ newVal ];
1010
in
1111
{
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+
1218
# Override go_1_24 to create go_1_25 with Windows platform support
1319
# Native nixpkgs go_1_25 doesn't support Windows (x86_64-windows not in meta.platforms)
1420
# By overriding go_1_24, we inherit its Windows support
1521
# 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 {
1729
version = "1.25.0";
1830
src = final.fetchurl {
1931
url = "https://go.dev/dl/go${version}.src.tar.gz";
2032
hash = "sha256-S9AekSlyB7+kUOpA1NWpOxtTGl5DhHOyoG4Y4HciciU=";
2133
};
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+
};
3761
});
3862
rocksdb = final.callPackage ./rocksdb.nix { };
3963
golangci-lint = final.callPackage ./golangci-lint.nix { };

nix/bundle-win-exe.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ runCommand "tarball-${cronosd.name}"
2020
"${bzip2.bin}/bin/libbz2-1.dll"
2121
"${zlib}/bin/zlib1.dll"
2222
"${zstd.bin}/bin/libzstd.dll"
23-
"${windows.mingw_w64_pthreads}/bin/libwinpthread-1.dll"
23+
"${windows.pthreads}/bin/libwinpthread-1.dll"
2424
"${windows.mcfgthreads}/bin/libmcfgthread-1.dll"
2525
"${stdenv.cc.cc.lib}/x86_64-w64-mingw32/lib/libgcc_s_seh-1.dll"
2626
"${stdenv.cc.cc.lib}/x86_64-w64-mingw32/lib/libstdc++-6.dll"

nix/cronos-matrix.nix

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@ builtins.listToAttrs (
4848
);
4949
value =
5050
let
51-
cronosd = callPackage ../. { inherit rev network; };
51+
# For cross-compilation, we need to use the build platform's Go compiler
52+
# not the target platform's Go
53+
cronosd = callPackage ../. {
54+
inherit rev network;
55+
go = buildPackages.go;
56+
};
5257
bundle = if stdenv.hostPlatform.isWindows then bundle-win-exe cronosd else bundle-exe cronosd;
5358
in
5459
if pkgtype == "bundle" then

0 commit comments

Comments
 (0)