2022-07-18 22:44:50 +01:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchurl
|
|
|
|
, dos2unix
|
|
|
|
, runCommand
|
|
|
|
, tinyscheme
|
|
|
|
}:
|
2019-01-08 01:05:38 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2019-08-15 13:41:18 +01:00
|
|
|
pname = "tinyscheme";
|
2021-03-09 23:02:02 +00:00
|
|
|
version = "1.42";
|
2019-01-08 01:05:38 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2019-08-15 13:41:18 +01:00
|
|
|
url = "mirror://sourceforge/tinyscheme/${pname}-${version}.tar.gz";
|
2021-03-09 23:02:02 +00:00
|
|
|
sha256 = "sha256-F7Cxv/0i89SdWDPiKhILM5A50s/aC0bW/FHdLwG0B60=";
|
2019-01-08 01:05:38 +00:00
|
|
|
};
|
|
|
|
|
2022-07-18 21:12:40 +01:00
|
|
|
nativeBuildInputs = [ dos2unix ];
|
|
|
|
|
|
|
|
prePatch = "dos2unix makefile";
|
|
|
|
patches = [
|
2022-07-18 21:13:20 +01:00
|
|
|
# The alternate macOS main makes use of `ccommand` which seems to be
|
|
|
|
# `MetroWerks CodeWarrier` specific:
|
|
|
|
# https://ptgmedia.pearsoncmg.com/imprint_downloads/informit/downloads/9780201703535/macfix.html
|
|
|
|
#
|
|
|
|
# In any case, this is not needed to build on macOS.
|
|
|
|
./01-remove-macOS-main.patch
|
|
|
|
|
2022-07-18 21:12:40 +01:00
|
|
|
# We want to have the makefile pick up $CC, etc. so that we don't have
|
|
|
|
# to unnecessarily tie this package to the GCC stdenv.
|
|
|
|
./02-use-toolchain-env-vars.patch
|
2022-07-18 21:13:20 +01:00
|
|
|
] ++ lib.optionals stdenv.targetPlatform.isDarwin [
|
|
|
|
# On macOS the library suffix is .dylib:
|
|
|
|
./03-macOS-SOsuf.patch
|
2022-07-18 21:12:40 +01:00
|
|
|
];
|
|
|
|
postPatch = ''
|
2019-01-08 01:05:38 +00:00
|
|
|
substituteInPlace scheme.c --replace "init.scm" "$out/lib/init.scm"
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/bin $out/lib
|
|
|
|
cp init.scm $out/lib
|
2022-07-18 21:11:04 +01:00
|
|
|
cp libtinyscheme* $out/lib
|
2019-01-08 01:05:38 +00:00
|
|
|
cp scheme $out/bin/tinyscheme
|
|
|
|
'';
|
|
|
|
|
2022-07-18 22:44:50 +01:00
|
|
|
passthru.tests = {
|
|
|
|
# Checks that the program can run and exit:
|
|
|
|
simple = runCommand "${pname}-simple-test" {} ''
|
|
|
|
${tinyscheme}/bin/tinyscheme <<<"(quit 0)"
|
|
|
|
echo "success" > $out
|
|
|
|
'';
|
|
|
|
fileIo = runCommand "${pname}-file-io-test" {} ''
|
|
|
|
${tinyscheme}/bin/tinyscheme <<EOF
|
|
|
|
(call-with-output-file "$out"
|
|
|
|
(lambda (p)
|
|
|
|
(begin
|
|
|
|
(write "success!" p)
|
|
|
|
(newline p)
|
|
|
|
)))
|
|
|
|
EOF
|
|
|
|
'';
|
|
|
|
helpText = runCommand "${pname}-help-text-test" {} ''
|
|
|
|
${tinyscheme}/bin/tinyscheme '-?' | tee > $out || :
|
|
|
|
[[ "$(cat $out)" =~ ^Usage: ]]
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2021-01-23 13:15:07 +00:00
|
|
|
meta = with lib; {
|
2019-01-08 01:05:38 +00:00
|
|
|
description = "Lightweight Scheme implementation";
|
|
|
|
longDescription = ''
|
|
|
|
TinyScheme is a lightweight Scheme interpreter that implements as large a
|
|
|
|
subset of R5RS as was possible without getting very large and complicated.
|
|
|
|
'';
|
2020-04-01 02:11:51 +01:00
|
|
|
homepage = "http://tinyscheme.sourceforge.net/";
|
2022-07-18 21:13:05 +01:00
|
|
|
changelog = "http://tinyscheme.sourceforge.net/CHANGES";
|
2019-01-08 01:05:38 +00:00
|
|
|
license = licenses.bsdOriginal;
|
2022-07-19 04:27:23 +01:00
|
|
|
mainProgram = pname;
|
2019-01-08 01:05:38 +00:00
|
|
|
maintainers = [ maintainers.ebzzry ];
|
|
|
|
platforms = platforms.unix;
|
|
|
|
};
|
|
|
|
}
|