-
-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lambda-lisp: init at 2022-08-18 #242101
lambda-lisp: init at 2022-08-18 #242101
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# Lambda Lisp has several backends, here we are using | ||
# the blc one. Ideally, this should be made into several | ||
# packages such as lambda-lisp-blc, lambda-lisp-lazyk, | ||
# lambda-lisp-clamb, etc. | ||
|
||
{ lib | ||
, gccStdenv | ||
, fetchFromGitHub | ||
, fetchurl | ||
, runtimeShell | ||
}: | ||
|
||
let | ||
stdenv = gccStdenv; | ||
s = import ./sources.nix { inherit fetchurl fetchFromGitHub; }; | ||
in | ||
stdenv.mkDerivation rec { | ||
pname = "lambda-lisp-blc"; | ||
version = s.lambdaLispVersion; | ||
src = s.src; | ||
flatSrc = s.flatSrc; | ||
blcSrc = s.blcSrc; | ||
|
||
installPhase = '' | ||
runHook preInstall | ||
|
||
mkdir -p ./build | ||
cp $blcSrc ./build/Blc.S | ||
cp $flatSrc ./build/flat.lds | ||
cd build; | ||
cat Blc.S | sed -e 's/#define.*TERMS.*//' > Blc.ext.S; | ||
$CC -c -DTERMS=50000000 -o Blc.o Blc.ext.S | ||
ld.bfd -o Blc Blc.o -T flat.lds | ||
cd ..; | ||
mv build/Blc ./bin | ||
install -D -t $out/bin bin/Blc | ||
install -D -t $out/lib bin/lambdalisp.blc | ||
|
||
cd build; | ||
$CC ../tools/asc2bin.c -O2 -o asc2bin; | ||
cd ..; | ||
mv build/asc2bin ./bin; | ||
chmod 755 ./bin/asc2bin; | ||
install -D -t $out/bin bin/asc2bin | ||
|
||
echo -e "#!${runtimeShell}\n( cat $out/lib/lambdalisp.blc | $out/bin/asc2bin; cat ) | $out/bin/Blc" > lambda-lisp-blc | ||
chmod +x lambda-lisp-blc | ||
|
||
install -D -t $out/bin lambda-lisp-blc | ||
runHook postInstall | ||
''; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to add some simple tests to installCheckPhase? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added one that covers a few arithmetic operations https://github.com/NixOS/nixpkgs/compare/14317ea8bc1b3b97fac3e577852706cf23da6f02..52bdc84582b499de50f4f4af2035d9eb9bc5ba61 |
||
doInstallCheck = true; | ||
|
||
installCheckPhase = '' | ||
runHook preInstallCheck | ||
|
||
a=$(echo "(* (+ 1 2 3 4 5 6 7 8 9 10) 12020569 (- 2 5))" | $out/bin/lambda-lisp-blc | tr -d "> "); | ||
test $a == -1983393885 | ||
|
||
runHook postInstallCheck | ||
''; | ||
|
||
meta = with lib; { | ||
description = "A Lisp interpreter written in untyped lambda calculus"; | ||
homepage = "https://github.com/woodrush/lambdalisp"; | ||
longDescription = '' | ||
LambdaLisp is a Lisp interpreter written as a closed untyped lambda calculus term. | ||
It is written as a lambda calculus term LambdaLisp = λx. ... which takes a string | ||
x as an input and returns a string as an output. The input x is the Lisp program | ||
and the user's standard input, and the output is the standard output. Characters | ||
are encoded into lambda term representations of natural numbers using the Church | ||
encoding, and strings are encoded as a list of characters with lists expressed as | ||
lambdas in the Mogensen-Scott encoding, so the entire computation process solely | ||
consists of the beta-reduction of lambda terms, without introducing any | ||
non-lambda-type object. | ||
''; | ||
license = licenses.mit; | ||
maintainers = with maintainers; [ cafkafk ]; | ||
platforms = [ "x86_64-linux" ]; | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
let | ||
lambdaLispVersion = "2022-08-18"; | ||
blcVersion = "2"; | ||
# Archive of "https://justine.lol/lambda/"; | ||
justineLolArchive = "https://web.archive.org/web/20230614065521if_/https://justine.lol/lambda/"; | ||
in | ||
{ fetchFromGitHub, fetchurl }: { | ||
inherit blcVersion; | ||
inherit lambdaLispVersion; | ||
|
||
src = fetchFromGitHub { | ||
owner = "woodrush"; | ||
repo = "lambdalisp"; | ||
rev = "2119cffed1ab2005f08ab3cfca92028270f08725"; | ||
hash = "sha256-ml2xQ8s8sux+6GwTw8mID3PEOcH6hn8tyc/UI5tFaO0="; | ||
}; | ||
|
||
uniCSrc = fetchFromGitHub { | ||
owner = "tromp"; | ||
repo = "tromp.github.io"; | ||
rev = "b4de12e566c1fb0fa3f3babe89bac885f4c966a4"; | ||
hash = "sha256-JmbqQp2kkkkkkkkSWQmG3uBxdgyIu4r2Ch8bBGyQ4H4="; | ||
}; | ||
|
||
# needed later | ||
clambSrc = fetchFromGitHub { | ||
owner = "irori"; | ||
repo = "clamb"; | ||
rev = "44c1208697f394e22857195be5ea73bfdd48ebd1"; | ||
hash = "sha256-1lGg2NBoxAKDCSnnPn19r/hwBC5paAKUnlcsUv3dpNY="; | ||
}; | ||
|
||
# needed later | ||
lazykSrc = fetchFromGitHub { | ||
owner = "irori"; | ||
repo = "lazyk"; | ||
rev = "5edb0b834d0af5f7413c484eb3795d47ec2e3894"; | ||
hash = "sha256-1lGg2NBoxAKDCSnnPn19r/hwBC5paAKUnlcsUv3dpNY="; | ||
}; | ||
|
||
blcSrc = fetchurl { | ||
url = "${justineLolArchive}Blc.S?v=${blcVersion}"; | ||
hash = "sha256-qt7vDtn9WvDoBaLESCyyscA0u74914e8ZKhLiUAN52A="; | ||
}; | ||
|
||
flatSrc = fetchurl { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please make a issue upstream asking them to vendor the files from lambda/ or checking for their existence before Or email justine to ask for the files to be put in a repo |
||
url = "${justineLolArchive}flat.lds"; | ||
hash = "sha256-HxX+10rV86zPv+UtF+n72obtz3DosWLMIab+uskxIjA="; | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mic92/nix-update#202 would make updating the
fetchFromGitHub
sources faster to update