nixpkgs/pkgs/development/compilers/ccl/default.nix

112 lines
3.5 KiB
Nix
Raw Normal View History

2020-08-03 04:22:13 +01:00
{ stdenv, fetchurl, runCommand, bootstrap_cmds, coreutils, glibc, m4, runtimeShell }:
2015-09-27 21:40:05 +01:00
let
options = rec {
2018-02-28 08:24:21 +00:00
/* TODO: there are also FreeBSD and Windows versions */
2015-09-27 21:40:05 +01:00
x86_64-linux = {
arch = "linuxx86";
2020-08-03 04:22:13 +01:00
sha256 = "0d5bsizgpw9hv0jfsf4bp5sf6kxh8f9hgzz9hsjzpfhs3npmmac4";
2015-09-27 21:40:05 +01:00
runtime = "lx86cl64";
kernel = "linuxx8664";
};
i686-linux = {
arch = "linuxx86";
sha256 = x86_64-linux.sha256;
runtime = "lx86cl";
kernel = "linuxx8632";
};
armv7l-linux = {
arch = "linuxarm";
2020-08-03 04:22:13 +01:00
sha256 = throw "ccl all-in-one linuxarm archive missing upstream";
2015-09-27 21:40:05 +01:00
runtime = "armcl";
kernel = "linuxarm";
};
2018-02-28 08:24:21 +00:00
x86_64-darwin = {
arch = "darwinx86";
2020-08-03 04:22:13 +01:00
sha256 = "1l060719k8mjd70lfdnr0hkybk7v88zxvfrsp7ww50q808cjffqk";
2018-02-28 08:24:21 +00:00
runtime = "dx86cl64";
kernel = "darwinx8664";
};
2015-09-27 21:40:05 +01:00
armv6l-linux = armv7l-linux;
};
2019-08-13 22:52:01 +01:00
cfg = options.${stdenv.hostPlatform.system} or (throw "missing source url for platform ${stdenv.hostPlatform.system}");
2020-08-03 04:22:13 +01:00
# The 1.12 github release of CCL seems to be missing the usual
# ccl-1.12-linuxarm.tar.gz tarball, so we build it ourselves here
linuxarm-src = runCommand "ccl-1.12-linuxarm.tar.gz" {
outer = fetchurl {
url = "https://github.com/Clozure/ccl/archive/v1.12.tar.gz";
sha256 = "0lmxhll6zgni0l41h4kcf3khbih9r0f8xni6zcfvbi3dzfs0cjkp";
};
inner = fetchurl {
url = "https://github.com/Clozure/ccl/releases/download/v1.12/linuxarm.tar.gz";
sha256 = "0x4bjx6cxsjvxyagijhlvmc7jkyxifdvz5q5zvz37028va65243c";
};
} ''
tar xf $outer
tar xf $inner -C ccl
tar czf $out ccl
'';
2015-09-27 21:40:05 +01:00
in
2015-10-01 10:20:24 +01:00
stdenv.mkDerivation rec {
pname = "ccl";
2020-08-03 04:22:13 +01:00
version = "1.12";
2020-08-03 04:22:13 +01:00
src = if cfg.arch == "linuxarm" then linuxarm-src else fetchurl {
2017-12-01 19:31:47 +00:00
url = "https://github.com/Clozure/ccl/releases/download/v${version}/ccl-${version}-${cfg.arch}.tar.gz";
2015-09-27 21:40:05 +01:00
sha256 = cfg.sha256;
};
2018-03-14 22:02:52 +00:00
buildInputs = if stdenv.isDarwin then [ bootstrap_cmds m4 ] else [ glibc m4 ];
2015-09-27 21:40:05 +01:00
CCL_RUNTIME = cfg.runtime;
CCL_KERNEL = cfg.kernel;
2018-02-28 08:24:21 +00:00
postPatch = if stdenv.isDarwin then ''
substituteInPlace lisp-kernel/${CCL_KERNEL}/Makefile \
--replace "M4 = gm4" "M4 = m4" \
--replace "dtrace" "/usr/sbin/dtrace" \
--replace "/bin/rm" "${coreutils}/bin/rm" \
--replace "/bin/echo" "${coreutils}/bin/echo"
substituteInPlace lisp-kernel/m4macros.m4 \
--replace "/bin/pwd" "${coreutils}/bin/pwd"
'' else ''
2014-11-29 06:14:53 +00:00
substituteInPlace lisp-kernel/${CCL_KERNEL}/Makefile \
--replace "/bin/rm" "${coreutils}/bin/rm" \
--replace "/bin/echo" "${coreutils}/bin/echo"
substituteInPlace lisp-kernel/m4macros.m4 \
--replace "/bin/pwd" "${coreutils}/bin/pwd"
'';
2014-11-29 06:14:53 +00:00
buildPhase = ''
make -C lisp-kernel/${CCL_KERNEL} clean
make -C lisp-kernel/${CCL_KERNEL} all
./${CCL_RUNTIME} -n -b -e '(ccl:rebuild-ccl :full t)' -e '(ccl:quit)'
'';
installPhase = ''
mkdir -p "$out/share"
cp -r . "$out/share/ccl-installation"
mkdir -p "$out/bin"
echo -e '#!${runtimeShell}\n'"$out/share/ccl-installation/${CCL_RUNTIME}"' "$@"\n' > "$out"/bin/"${CCL_RUNTIME}"
chmod a+x "$out"/bin/"${CCL_RUNTIME}"
ln -s "$out"/bin/"${CCL_RUNTIME}" "$out"/bin/ccl
'';
hardeningDisable = [ "format" ];
2015-10-01 10:20:24 +01:00
meta = with stdenv.lib; {
description = "Clozure Common Lisp";
homepage = "https://ccl.clozure.com/";
2015-11-24 22:26:26 +00:00
maintainers = with maintainers; [ raskin muflax tohl ];
2015-10-01 10:20:24 +01:00
platforms = attrNames options;
2020-08-03 04:22:13 +01:00
license = licenses.asl20;
};
}