1{ stdenv, fetchurl, swiProlog, haskellPackages
2, glibcLocales, makeWrapper, rlwrap, tk, which }:
3
4let
5 fname = "pakcs-1.14.0";
6
7 fsrc = fetchurl {
8 url = "http://www.informatik.uni-kiel.de/~pakcs/download/${fname}-src.tar.gz";
9 sha256 = "1651ssh4ql79x8asd7kp4yis2n5rhn3lml4s26y03b0cgbfhs78s";
10 };
11
12 swiPrologLocked = stdenv.lib.overrideDerivation swiProlog (oldAttrs: rec {
13 version = "6.6.6";
14 name = "swi-prolog-${version}";
15 src = fetchurl {
16 url = "http://www.swi-prolog.org/download/stable/src/pl-${version}.tar.gz";
17 sha256 = "0vcrfskm2hyhv30lxr6v261myb815jc3bgmcn1lgsc9g9qkvp04z";
18 };
19 });
20
21in
22stdenv.mkDerivation rec {
23
24 name = fname;
25
26 curryBase = haskellPackages.callPackage (
27 { mkDerivation, base, Cabal, containers, directory, either
28 , filepath, mtl, pretty, stdenv, syb, time
29 }:
30 mkDerivation {
31 pname = "curry-base";
32 version = "0.4.1";
33 src = fsrc;
34 libraryHaskellDepends = [
35 base containers directory either filepath mtl pretty syb time
36 ];
37 testHaskellDepends = [ base Cabal filepath mtl ];
38 homepage = http://curry-language.org;
39 description = "Functions for manipulating Curry programs";
40 license = "unknown";
41
42 postUnpack = ''
43 mv ${name} ${name}.orig
44 ln -s ${name}.orig/frontend/curry-base ${name}
45 '';
46 doCheck = false;
47 }
48 ) {};
49
50 curryFront = haskellPackages.callPackage (
51 { mkDerivation, base, Cabal, containers, directory
52 , filepath, mtl, network-uri, process, stdenv, syb, transformers
53 }:
54 mkDerivation {
55 pname = "curry-frontend";
56 version = "0.4.1";
57 src = fsrc;
58 isLibrary = true;
59 isExecutable = true;
60 libraryHaskellDepends = [
61 base containers curryBase directory filepath mtl network-uri
62 process syb transformers
63 ];
64 executableHaskellDepends = [
65 base containers curryBase directory filepath mtl network-uri
66 process syb transformers
67 ];
68 testHaskellDepends = [ base Cabal curryBase filepath ];
69 homepage = http://curry-language.org;
70 description = "Compile the functional logic language Curry to several intermediate formats";
71 license = "unknown";
72
73 postUnpack = ''
74 mv ${name} ${name}.orig
75 ln -s ${name}.orig/frontend/curry-frontend ${name}
76 '';
77 doCheck = false;
78 }
79 ) {};
80
81 src = fsrc;
82
83 buildInputs = [ swiPrologLocked makeWrapper glibcLocales rlwrap tk which ];
84
85 patches = [
86 ./adjust-buildsystem.patch
87 ./case-insensitive.patch
88 ];
89
90 configurePhase = ''
91 # Phony HOME.
92 mkdir phony-home
93 export HOME=$(pwd)/phony-home
94
95 # SWI Prolog
96 sed -i 's@SWIPROLOG=@SWIPROLOG='${swiPrologLocked}/bin/swipl'@' scripts/pakcsinitrc.sh
97 '';
98
99 buildPhase = ''
100 # Some comments in files are in UTF-8, so include the locale needed by GHC runtime.
101 export LC_ALL=en_US.UTF-8
102
103 # PAKCS must be build in place due to embedded filesystem references placed by swi.
104
105 # Prepare PAKCSHOME directory.
106 mkdir -p $out/pakcs/bin
107
108 # Set up link to cymake, which has been built already.
109 ln -s ${curryFront}/bin/cymake $out/pakcs/bin/
110 rm -r frontend
111
112 # Prevent embedding the derivation build directory as temp.
113 export TEMP=/tmp
114
115 # Copy to in place build location and run the build.
116 cp -r * $out/pakcs
117 (cd $out/pakcs ; make)
118 '';
119
120 installPhase = ''
121 # Install bin.
122 mkdir -p $out/bin
123 for b in $(ls $out/pakcs/bin) ; do
124 ln -s $out/pakcs/bin/$b $out/bin/ ;
125 done
126
127 # Place emacs lisp files in expected locations.
128 mkdir -p $out/share/emacs/site-lisp/curry-pakcs
129 for e in "$out/pakcs/tools/emacs/"*.el ; do
130 cp $e $out/share/emacs/site-lisp/curry-pakcs/ ;
131 done
132
133 # Wrap for rlwrap and tk support.
134 wrapProgram $out/pakcs/bin/pakcs \
135 --prefix PATH ":" "${rlwrap}/bin" \
136 --prefix PATH ":" "${tk}/bin" \
137 '';
138
139 meta = with stdenv.lib; {
140 homepage = http://www.informatik.uni-kiel.de/~pakcs/;
141 description = "An implementation of the multi-paradigm declarative language Curry";
142 license = licenses.bsd3;
143
144 longDescription = ''
145 PAKCS is an implementation of the multi-paradigm declarative language
146 Curry jointly developed by the Portland State University, the Aachen
147 University of Technology, and the University of Kiel. Although this is
148 not a highly optimized implementation but based on a high-level
149 compilation of Curry programs into Prolog programs, it is not a toy
150 implementation but has been used for a variety of applications (e.g.,
151 graphical programming environments, an object-oriented front-end for
152 Curry, partial evaluators, database applications, HTML programming
153 with dynamic web pages, prototyping embedded systems).
154 '';
155
156 maintainers = with maintainers; [ kkallio gnidorah ];
157 platforms = platforms.unix;
158 };
159}