1{ lib, stdenv, fetchurl
2, libiconv
3, libpng
4, ncurses
5, pcre
6, readline
7, zlib
8, writeScript
9}:
10
11stdenv.mkDerivation rec {
12 pname = "slang";
13 version = "2.3.3";
14
15 src = fetchurl {
16 url = "https://www.jedsoft.org/releases/slang/${pname}-${version}.tar.bz2";
17 sha256 = "sha256-+RRQVK4TGXPGEgjqgkhtXdEOPFza0jt8SgYXdDyPWhg=";
18 };
19
20 outputs = [ "out" "dev" "man" "doc" ];
21
22 # Fix some wrong hardcoded paths
23 preConfigure = ''
24 sed -ie "s|/usr/lib/terminfo|${ncurses.out}/lib/terminfo|" configure
25 sed -ie "s|/usr/lib/terminfo|${ncurses.out}/lib/terminfo|" src/sltermin.c
26 sed -ie "s|/bin/ln|ln|" src/Makefile.in
27 sed -ie "s|-ltermcap|-lncurses|" ./configure
28 '';
29
30 configureFlags = [
31 "--with-pcre=${pcre.dev}"
32 "--with-png=${libpng.dev}"
33 "--with-readline=${readline.dev}"
34 "--with-z=${zlib.dev}"
35 ];
36
37 buildInputs = [
38 libpng
39 pcre
40 readline
41 zlib
42 ] ++ lib.optionals (stdenv.isDarwin) [ libiconv ];
43
44 propagatedBuildInputs = [ ncurses ];
45
46 buildFlags = lib.optional stdenv.hostPlatform.isStatic "static";
47 installTargets = lib.optional stdenv.hostPlatform.isStatic "install-static";
48
49 preBuild = ''
50 makeFlagsArray+=(AR_CR="${stdenv.cc.targetPrefix}ar cr")
51 '';
52
53 enableParallelBuilding = true;
54
55 postInstall = ''
56 find "$out"/lib/ -name '*.so' -exec chmod +x "{}" \;
57 sed '/^Libs:/s/$/ -lncurses/' -i "$dev"/lib/pkgconfig/slang.pc
58 '';
59
60 passthru = {
61 updateScript = writeScript "update-slang" ''
62 #!/usr/bin/env nix-shell
63 #!nix-shell -i bash -p curl pcre common-updater-scripts
64
65 set -eu -o pipefail
66
67 # Expect the text in format of 'Version 2.3.3</td>'
68 new_version="$(curl -s https://www.jedsoft.org/slang/ |
69 pcregrep -o1 'Version ([0-9.]+)</td>')"
70 update-source-version ${pname} "$new_version"
71 '';
72 };
73
74 meta = with lib; {
75 description = "A small, embeddable multi-platform programming library";
76 longDescription = ''
77 S-Lang is an interpreted language that was designed from the start to be
78 easily embedded into a program to provide it with a powerful extension
79 language. Examples of programs that use S-Lang as an extension language
80 include the jed text editor and the slrn newsreader. Although S-Lang does
81 not exist as a separate application, it is distributed with a quite
82 capable program called slsh ("slang-shell") that embeds the interpreter
83 and allows one to execute S-Lang scripts, or simply experiment with S-Lang
84 at an interactive prompt. Many of the the examples in this document are
85 presented in the context of one of the above applications.
86
87 S-Lang is also a programmer's library that permits a programmer to develop
88 sophisticated platform-independent software. In addition to providing the
89 S-Lang interpreter, the library provides facilities for screen management,
90 keymaps, low-level terminal I/O, etc. However, this document is concerned
91 only with the extension language and does not address these other features
92 of the S-Lang library. For information about the other components of the
93 library, the reader is referred to the S-Lang Library C Programmer's
94 Guide.
95 '';
96 homepage = "http://www.jedsoft.org/slang/";
97 license = licenses.gpl2Plus;
98 maintainers = with maintainers; [ AndersonTorres ];
99 mainProgram = "slsh";
100 platforms = platforms.unix;
101 };
102}