Skip to content

Commit de1f6ee

Browse files
committed
feature(nix): Enable aarch64-multiplatform-musl via crossPlatforms
1 parent 3ce782e commit de1f6ee

File tree

1 file changed

+52
-5
lines changed

1 file changed

+52
-5
lines changed

flake.nix

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,12 @@
160160
in
161161
lib.genAttrs compilers (c: { compiler-nix-name = c; });
162162

163+
crossPlatforms = p:
164+
lib.optional (system == "x86_64-linux") p.musl64 ++
165+
lib.optional
166+
(system == "x86_64-linux" && config.compiler-nix-name == "ghc966")
167+
p.aarch64-multiplatform-musl;
168+
163169
inputMap = {
164170
"https://chap.intersectmbo.org/" = inputs.CHaP;
165171
};
@@ -249,6 +255,51 @@
249255
packages.cardano-chain-gen.components.tests.cardano-chain-gen =
250256
postgresTest;
251257
})
258+
259+
({
260+
packages.double-conversion.ghcOptions = [
261+
# stop putting U __gxx_personality_v0 into the library!
262+
"-optcxx-fno-rtti"
263+
"-optcxx-fno-exceptions"
264+
# stop putting U __cxa_guard_release into the library!
265+
"-optcxx-std=gnu++98"
266+
"-optcxx-fno-threadsafe-statics"
267+
];
268+
})
269+
270+
(lib.mkIf pkgs.haskell-nix.haskellLib.isCrossHost {
271+
packages.text-icu.patches = [
272+
# Fix the following compilation error when cross-compiling:
273+
#
274+
# Char.hsc: In function ‘_hsc2hs_test45’:
275+
# Char.hsc:1227:20: error: storage size of ‘test_array’ isn’t constant
276+
# Char.hsc:1227:20: warning: unused variable ‘test_array’ [8;;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wunused-variable-Wunused-variable8;;]
277+
# compilation failed
278+
#
279+
# U_NO_NUMERIC_VALUE is defined to be `((double)-123456789.)` which gcc can't
280+
# figure out at compile time.
281+
#
282+
# More context:
283+
#
284+
# https://github.com/haskell/text-icu/issues/7
285+
# https://gitlab.haskell.org/ghc/ghc/-/issues/7983
286+
# https://gitlab.haskell.org/ghc/ghc/-/issues/12849
287+
(builtins.toFile "text-icu.patch" ''
288+
diff --git c/Data/Text/ICU/Char.hsc i/Data/Text/ICU/Char.hsc
289+
index 6ea2b39..a0bf995 100644
290+
--- c/Data/Text/ICU/Char.hsc
291+
+++ i/Data/Text/ICU/Char.hsc
292+
@@ -1223,7 +1223,7 @@ digitToInt c
293+
-- fractions, negative, or too large to fit in a fixed-width integral type.
294+
numericValue :: Char -> Maybe Double
295+
numericValue c
296+
- | v == (#const U_NO_NUMERIC_VALUE) = Nothing
297+
+ | v == -123456789 = Nothing
298+
| otherwise = Just v
299+
where v = u_getNumericValue . fromIntegral . ord $ c
300+
'')
301+
];
302+
})
252303
];
253304
})).appendOverlays [
254305
# Collect local package `exe`s
@@ -287,11 +338,7 @@
287338
shellcheck = callPackage shellCheck { inherit src; };
288339
};
289340

290-
flake = project.flake (
291-
nixpkgs.lib.optionalAttrs (system == "x86_64-linux") {
292-
crossPlatforms = p: [p.musl64];
293-
}
294-
);
341+
flake = project.flake {};
295342
in with nixpkgs; lib.recursiveUpdate flake (
296343
let
297344
mkDist = platform: project:

0 commit comments

Comments
 (0)