at master 3.2 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchurl, 5 bootstrap_cmds, 6 coreutils, 7 glibc, 8 m4, 9 runtimeShell, 10}: 11 12let 13 options = rec { 14 # TODO: there are also FreeBSD and Windows versions 15 x86_64-linux = { 16 arch = "linuxx86"; 17 sha256 = "0mhmm8zbk42p2b9amy702365m687k5p0xnz010yqrki6mwyxlkx9"; 18 runtime = "lx86cl64"; 19 kernel = "linuxx8664"; 20 }; 21 i686-linux = { 22 arch = "linuxx86"; 23 sha256 = x86_64-linux.sha256; 24 runtime = "lx86cl"; 25 kernel = "linuxx8632"; 26 }; 27 armv7l-linux = { 28 arch = "linuxarm"; 29 sha256 = "1a4y07cmmn1r88b4hl4msb0bvr2fxd2vw9lf7h4j9f7a5rpq7124"; 30 runtime = "armcl"; 31 kernel = "linuxarm"; 32 }; 33 x86_64-darwin = { 34 arch = "darwinx86"; 35 sha256 = "1xclnik6pqhkmr15cbqa2n1ddzdf0rs452lyiln3c42nmkf9jjb6"; 36 runtime = "dx86cl64"; 37 kernel = "darwinx8664"; 38 }; 39 armv6l-linux = armv7l-linux; 40 }; 41 cfg = 42 options.${stdenv.hostPlatform.system} 43 or (throw "missing source url for platform ${stdenv.hostPlatform.system}"); 44 45in 46stdenv.mkDerivation rec { 47 pname = "ccl"; 48 version = "1.12.2"; 49 50 src = fetchurl { 51 url = "https://github.com/Clozure/ccl/releases/download/v${version}/ccl-${version}-${cfg.arch}.tar.gz"; 52 sha256 = cfg.sha256; 53 }; 54 55 buildInputs = 56 if stdenv.hostPlatform.isDarwin then 57 [ 58 bootstrap_cmds 59 m4 60 ] 61 else 62 [ 63 glibc 64 m4 65 ]; 66 67 CCL_RUNTIME = cfg.runtime; 68 CCL_KERNEL = cfg.kernel; 69 70 postPatch = 71 if stdenv.hostPlatform.isDarwin then 72 '' 73 substituteInPlace lisp-kernel/${CCL_KERNEL}/Makefile \ 74 --replace "M4 = gm4" "M4 = m4" \ 75 --replace "dtrace" "/usr/sbin/dtrace" \ 76 --replace "/bin/rm" "${coreutils}/bin/rm" \ 77 --replace "/bin/echo" "${coreutils}/bin/echo" 78 79 substituteInPlace lisp-kernel/m4macros.m4 \ 80 --replace "/bin/pwd" "${coreutils}/bin/pwd" 81 '' 82 else 83 '' 84 substituteInPlace lisp-kernel/${CCL_KERNEL}/Makefile \ 85 --replace "/bin/rm" "${coreutils}/bin/rm" \ 86 --replace "/bin/echo" "${coreutils}/bin/echo" 87 88 substituteInPlace lisp-kernel/m4macros.m4 \ 89 --replace "/bin/pwd" "${coreutils}/bin/pwd" 90 ''; 91 92 buildPhase = '' 93 make -C lisp-kernel/${CCL_KERNEL} clean 94 make -C lisp-kernel/${CCL_KERNEL} all 95 96 ./${CCL_RUNTIME} -n -b -e '(ccl:rebuild-ccl :full t)' -e '(ccl:quit)' 97 ''; 98 99 installPhase = '' 100 mkdir -p "$out/share" 101 cp -r . "$out/share/ccl-installation" 102 103 mkdir -p "$out/bin" 104 echo -e '#!${runtimeShell}\n'"$out/share/ccl-installation/${CCL_RUNTIME}"' "$@"\n' > "$out"/bin/"${CCL_RUNTIME}" 105 chmod a+x "$out"/bin/"${CCL_RUNTIME}" 106 ln -s "$out"/bin/"${CCL_RUNTIME}" "$out"/bin/ccl 107 ''; 108 109 hardeningDisable = [ "format" ]; 110 111 meta = with lib; { 112 # assembler failures during build, x86_64-darwin broken since 2020-10-14 113 broken = (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64); 114 description = "Clozure Common Lisp"; 115 homepage = "https://ccl.clozure.com/"; 116 license = licenses.asl20; 117 mainProgram = "ccl"; 118 teams = [ lib.teams.lisp ]; 119 platforms = attrNames options; 120 }; 121}