1{
2 lib,
3 stdenv,
4 fetchurl,
5 makeWrapper,
6 darwin,
7 bootstrap-chicken ? null,
8 testers,
9}:
10
11let
12 platform =
13 with stdenv;
14 if isDarwin then
15 "macosx"
16 else if isCygwin then
17 "cygwin"
18 else if (isFreeBSD || isOpenBSD) then
19 "bsd"
20 else if isSunOS then
21 "solaris"
22 else
23 "linux"; # Should be a sane default
24in
25stdenv.mkDerivation (finalAttrs: {
26 pname = "chicken";
27 version = "5.4.0";
28
29 binaryVersion = 11;
30
31 src = fetchurl {
32 url = "https://code.call-cc.org/releases/${finalAttrs.version}/chicken-${finalAttrs.version}.tar.gz";
33 sha256 = "sha256-PF1KphwRZ79tm/nq+JHadjC6n188Fb8JUVpwOb/N7F8=";
34 };
35
36 # Disable two broken tests: "static link" and "linking tests"
37 postPatch = ''
38 sed -i tests/runtests.sh -e "/static link/,+4 { s/^/# / }"
39 sed -i tests/runtests.sh -e "/linking tests/,+11 { s/^/# / }"
40 '';
41
42 setupHook = lib.optional (bootstrap-chicken != null) ./setup-hook.sh;
43
44 makeFlags = [
45 "PLATFORM=${platform}"
46 "PREFIX=$(out)"
47 "C_COMPILER=$(CC)"
48 "CXX_COMPILER=$(CXX)"
49 ]
50 ++ (lib.optionals stdenv.hostPlatform.isDarwin [
51 "XCODE_TOOL_PATH=${darwin.binutils.bintools}/bin"
52 "LINKER_OPTIONS=-headerpad_max_install_names"
53 "POSTINSTALL_PROGRAM=install_name_tool"
54 ])
55 ++ (lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
56 "HOSTSYSTEM=${stdenv.hostPlatform.config}"
57 "TARGET_C_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc"
58 "TARGET_CXX_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++"
59 ]);
60
61 nativeBuildInputs = [
62 makeWrapper
63 ]
64 ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [
65 darwin.autoSignDarwinBinariesHook
66 ];
67
68 buildInputs = lib.optionals (bootstrap-chicken != null) [
69 bootstrap-chicken
70 ];
71
72 doCheck = !stdenv.hostPlatform.isDarwin;
73 postCheck = ''
74 ./csi -R chicken.pathname -R chicken.platform \
75 -p "(assert (equal? \"${toString finalAttrs.binaryVersion}\" (pathname-file (car (repository-path)))))"
76 '';
77
78 passthru.tests.version = testers.testVersion {
79 package = finalAttrs.finalPackage;
80 command = "csi -version";
81 };
82
83 meta = {
84 homepage = "https://call-cc.org/";
85 license = lib.licenses.bsd3;
86 maintainers = with lib.maintainers; [
87 corngood
88 nagy
89 konst-aa
90 ];
91 platforms = lib.platforms.unix;
92 description = "Portable compiler for the Scheme programming language";
93 longDescription = ''
94 CHICKEN is a compiler for the Scheme programming language.
95 CHICKEN produces portable and efficient C, supports almost all
96 of the R5RS Scheme language standard, and includes many
97 enhancements and extensions. CHICKEN runs on Linux, macOS,
98 Windows, and many Unix flavours.
99 '';
100 };
101})