Skip to content

Commit e9c5e6b

Browse files
committed
tdlib: fix cross-compilation
1 parent 9abb87b commit e9c5e6b

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

pkgs/by-name/td/tdlib/package.nix

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
writeShellApplication,
1111
common-updater-scripts,
1212
jq,
13+
buildPackages,
1314
}:
1415

1516
let
@@ -49,12 +50,28 @@ stdenv.mkDerivation {
4950
};
5051

5152
buildInputs = [
52-
gperf
5353
openssl
5454
readline
5555
zlib
5656
];
57-
nativeBuildInputs = [ cmake ];
57+
58+
nativeBuildInputs = [
59+
cmake
60+
gperf
61+
];
62+
63+
depsBuildBuild = [ buildPackages.stdenv.cc ];
64+
65+
preConfigure = lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) ''
66+
cmake -B native-build \
67+
-DCMAKE_C_COMPILER=$CC_FOR_BUILD \
68+
-DCMAKE_CXX_COMPILER=$CXX_FOR_BUILD \
69+
-DCMAKE_AR=$(command -v $AR_FOR_BUILD) \
70+
-DCMAKE_RANLIB=$(command -v $RANLIB_FOR_BUILD) \
71+
-DCMAKE_STRIP=$(command -v $STRIP_FOR_BUILD) \
72+
-DTD_GENERATE_SOURCE_FILES=ON .
73+
cmake --build native-build -j $NIX_BUILD_CORES
74+
'';
5875

5976
# https://github.com/tdlib/td/issues/1974
6077
postPatch =

0 commit comments

Comments
 (0)