1 # Lambda Lisp has several backends, here we are using
2 # the blc one. Ideally, this should be made into several
3 # packages such as lambda-lisp-blc, lambda-lisp-lazyk,
4 # lambda-lisp-clamb, etc.
15 s = import ./sources.nix { inherit fetchurl fetchFromGitHub; };
17 stdenv.mkDerivation rec {
18 pname = "lambda-lisp-blc";
19 version = s.lambdaLispVersion;
28 cp $blcSrc ./build/Blc.S
29 cp $flatSrc ./build/flat.lds
31 cat Blc.S | sed -e 's/#define.*TERMS.*//' > Blc.ext.S;
32 $CC -c -DTERMS=50000000 -o Blc.o Blc.ext.S
33 ld.bfd -o Blc Blc.o -T flat.lds
36 install -D -t $out/bin bin/Blc
37 install -D -t $out/lib bin/lambdalisp.blc
40 $CC ../tools/asc2bin.c -O2 -o asc2bin;
42 mv build/asc2bin ./bin;
43 chmod 755 ./bin/asc2bin;
44 install -D -t $out/bin bin/asc2bin
46 echo -e "#!${runtimeShell}\n( cat $out/lib/lambdalisp.blc | $out/bin/asc2bin; cat ) | $out/bin/Blc" > lambda-lisp-blc
47 chmod +x lambda-lisp-blc
49 install -D -t $out/bin lambda-lisp-blc
53 doInstallCheck = true;
55 installCheckPhase = ''
56 runHook preInstallCheck
58 a=$(echo "(* (+ 1 2 3 4 5 6 7 8 9 10) 12020569 (- 2 5))" | $out/bin/lambda-lisp-blc | tr -d "> ");
59 test $a == -1983393885
61 runHook postInstallCheck
65 description = "Lisp interpreter written in untyped lambda calculus";
66 homepage = "https://github.com/woodrush/lambdalisp";
68 LambdaLisp is a Lisp interpreter written as a closed untyped lambda calculus term.
69 It is written as a lambda calculus term LambdaLisp = λx. ... which takes a string
70 x as an input and returns a string as an output. The input x is the Lisp program
71 and the user's standard input, and the output is the standard output. Characters
72 are encoded into lambda term representations of natural numbers using the Church
73 encoding, and strings are encoded as a list of characters with lists expressed as
74 lambdas in the Mogensen-Scott encoding, so the entire computation process solely
75 consists of the beta-reduction of lambda terms, without introducing any
76 non-lambda-type object.
78 license = licenses.mit;
79 maintainers = with maintainers; [ cafkafk ];
80 platforms = [ "x86_64-linux" ];