1{ lib, stdenv, fetchurl, gmp
2, withEmacsSupport ? true
3, withContrib ? true }:
4
5let
6 versionPkg = "0.4.2";
7
8 contrib = fetchurl {
9 url = "mirror://sourceforge/ats2-lang/ATS2-Postiats-contrib-${versionPkg}.tgz";
10 hash = "sha256-m0hfBLsaNiLaIktcioK+ZtWUsWht3IDSJ6CzgJmS06c=";
11 };
12
13 postInstallContrib = lib.optionalString withContrib
14 ''
15 local contribDir=$out/lib/ats2-postiats-*/ ;
16 mkdir -p $contribDir ;
17 tar -xzf "${contrib}" --strip-components 1 -C $contribDir ;
18 '';
19
20 postInstallEmacs = lib.optionalString withEmacsSupport
21 ''
22 local siteLispDir=$out/share/emacs/site-lisp/ats2 ;
23 mkdir -p $siteLispDir ;
24 install -m 0644 -v ./utils/emacs/*.el $siteLispDir ;
25 '';
26in
27
28stdenv.mkDerivation rec {
29 pname = "ats2";
30 version = versionPkg;
31
32 src = fetchurl {
33 url = "mirror://sourceforge/ats2-lang/ATS2-Postiats-gmp-${version}.tgz";
34 hash = "sha256-UWgDjFojPBYgykrCrJyYvVWY+Gc5d4aRGjTWjc528AM=";
35 };
36
37 postPatch = lib.optionalString stdenv.cc.isClang ''
38 sed -i 's/gcc/clang/g' utils/*/DATS/atscc_util.dats
39 '';
40
41 buildInputs = [ gmp ];
42
43 # Disable parallel build, errors:
44 # *** No rule to make target 'patscc.dats', needed by 'patscc_dats.c'. Stop.
45 enableParallelBuilding = false;
46
47 makeFlags = [
48 "CC=${stdenv.cc.targetPrefix}cc"
49 "CCOMP=${stdenv.cc.targetPrefix}cc"
50 ];
51
52 setupHook = with lib;
53 let
54 hookFiles =
55 [ ./setup-hook.sh ]
56 ++ optional withContrib ./setup-contrib-hook.sh;
57 in
58 builtins.toFile "setupHook.sh"
59 (concatMapStringsSep "\n" builtins.readFile hookFiles);
60
61 postInstall = postInstallContrib + postInstallEmacs;
62
63 meta = with lib; {
64 description = "Functional programming language with dependent types";
65 homepage = "http://www.ats-lang.org";
66 license = licenses.gpl3Plus;
67 platforms = platforms.unix;
68 maintainers = with maintainers; [ thoughtpolice ttuegel bbarker ];
69 };
70}