github-backup: 0.48.0 -> 0.49.0 (#379003)
[NixPkgs.git] / pkgs / by-name / ti / tinyscheme / package.nix
blob4d6f5dca769b49dd24a7ff55e61cf83948ae4056
2   lib,
3   stdenv,
4   fetchurl,
5   dos2unix,
6   runCommand,
7   tinyscheme,
8 }:
10 stdenv.mkDerivation rec {
11   pname = "tinyscheme";
12   version = "1.42";
14   src = fetchurl {
15     url = "mirror://sourceforge/tinyscheme/${pname}-${version}.tar.gz";
16     sha256 = "sha256-F7Cxv/0i89SdWDPiKhILM5A50s/aC0bW/FHdLwG0B60=";
17   };
19   nativeBuildInputs = [ dos2unix ];
21   prePatch = "dos2unix makefile";
22   patches =
23     [
24       # The alternate macOS main makes use of `ccommand` which seems to be
25       # `MetroWerks CodeWarrier` specific:
26       # https://ptgmedia.pearsoncmg.com/imprint_downloads/informit/downloads/9780201703535/macfix.html
27       #
28       # In any case, this is not needed to build on macOS.
29       ./01-remove-macOS-main.patch
31       # We want to have the makefile pick up $CC, etc. so that we don't have
32       # to unnecessarily tie this package to the GCC stdenv.
33       ./02-use-toolchain-env-vars.patch
34     ]
35     ++ lib.optionals stdenv.hostPlatform.isDarwin [
36       # On macOS the library suffix is .dylib:
37       ./03-macOS-SOsuf.patch
38     ];
39   postPatch = ''
40     substituteInPlace scheme.c --replace "init.scm" "$out/lib/init.scm"
41   '';
43   installPhase = ''
44     mkdir -p $out/bin $out/lib
45     cp init.scm $out/lib
46     cp libtinyscheme* $out/lib
47     cp scheme $out/bin/tinyscheme
48   '';
50   passthru.tests = {
51     # Checks that the program can run and exit:
52     simple = runCommand "${pname}-simple-test" { } ''
53       ${tinyscheme}/bin/tinyscheme <<<"(quit 0)"
54       echo "success" > $out
55     '';
56     fileIo = runCommand "${pname}-file-io-test" { } ''
57       ${tinyscheme}/bin/tinyscheme <<EOF
58         (call-with-output-file "$out"
59           (lambda (p)
60             (begin
61                 (write "success!" p)
62                 (newline p)
63             )))
64       EOF
65     '';
66     helpText = runCommand "${pname}-help-text-test" { } ''
67       ${tinyscheme}/bin/tinyscheme '-?' | tee > $out || :
68       [[ "$(cat $out)" =~ ^Usage: ]]
69     '';
70   };
72   meta = with lib; {
73     description = "Lightweight Scheme implementation";
74     longDescription = ''
75       TinyScheme is a lightweight Scheme interpreter that implements as large a
76       subset of R5RS as was possible without getting very large and complicated.
77     '';
78     homepage = "https://tinyscheme.sourceforge.net/";
79     changelog = "https://tinyscheme.sourceforge.net/CHANGES";
80     license = licenses.bsdOriginal;
81     mainProgram = "tinyscheme";
82     maintainers = [ maintainers.ebzzry ];
83     platforms = platforms.unix;
84   };