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