Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
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. 5 6{ 7 lib, 8 gccStdenv, 9 fetchFromGitHub, 10 fetchurl, 11 runtimeShell, 12}: 13 14let 15 stdenv = gccStdenv; 16 s = import ./sources.nix { inherit fetchurl fetchFromGitHub; }; 17in 18stdenv.mkDerivation { 19 pname = "lambda-lisp-blc"; 20 version = s.lambdaLispVersion; 21 src = s.src; 22 flatSrc = s.flatSrc; 23 blcSrc = s.blcSrc; 24 25 installPhase = '' 26 runHook preInstall 27 28 mkdir -p ./build 29 cp $blcSrc ./build/Blc.S 30 cp $flatSrc ./build/flat.lds 31 cd build; 32 cat Blc.S | sed -e 's/#define.*TERMS.*//' > Blc.ext.S; 33 $CC -c -DTERMS=50000000 -o Blc.o Blc.ext.S 34 ld.bfd -o Blc Blc.o -T flat.lds 35 cd ..; 36 mv build/Blc ./bin 37 install -D -t $out/bin bin/Blc 38 install -D -t $out/lib bin/lambdalisp.blc 39 40 cd build; 41 $CC ../tools/asc2bin.c -O2 -o asc2bin; 42 cd ..; 43 mv build/asc2bin ./bin; 44 chmod 755 ./bin/asc2bin; 45 install -D -t $out/bin bin/asc2bin 46 47 echo -e "#!${runtimeShell}\n( cat $out/lib/lambdalisp.blc | $out/bin/asc2bin; cat ) | $out/bin/Blc" > lambda-lisp-blc 48 chmod +x lambda-lisp-blc 49 50 install -D -t $out/bin lambda-lisp-blc 51 runHook postInstall 52 ''; 53 54 doInstallCheck = true; 55 56 installCheckPhase = '' 57 runHook preInstallCheck 58 59 a=$(echo "(* (+ 1 2 3 4 5 6 7 8 9 10) 12020569 (- 2 5))" | $out/bin/lambda-lisp-blc | tr -d "> "); 60 test $a == -1983393885 61 62 runHook postInstallCheck 63 ''; 64 65 meta = with lib; { 66 description = "Lisp interpreter written in untyped lambda calculus"; 67 homepage = "https://github.com/woodrush/lambdalisp"; 68 longDescription = '' 69 LambdaLisp is a Lisp interpreter written as a closed untyped lambda calculus term. 70 It is written as a lambda calculus term LambdaLisp = λx. ... which takes a string 71 x as an input and returns a string as an output. The input x is the Lisp program 72 and the user's standard input, and the output is the standard output. Characters 73 are encoded into lambda term representations of natural numbers using the Church 74 encoding, and strings are encoded as a list of characters with lists expressed as 75 lambdas in the Mogensen-Scott encoding, so the entire computation process solely 76 consists of the beta-reduction of lambda terms, without introducing any 77 non-lambda-type object. 78 ''; 79 license = licenses.mit; 80 maintainers = with maintainers; [ cafkafk ]; 81 platforms = [ "x86_64-linux" ]; 82 }; 83}