1{
2 lib,
3 stdenv,
4 fetchurl,
5 pkg-config,
6 guile,
7 flex,
8 fetchpatch,
9}:
10
11stdenv.mkDerivation rec {
12 version = "1.1.11";
13 pname = "libmatheval";
14
15 nativeBuildInputs = [
16 pkg-config
17 flex
18 ];
19 buildInputs = [ guile ];
20
21 src = fetchurl {
22 url = "https://ftp.gnu.org/gnu/libmatheval/${pname}-${version}.tar.gz";
23 sha256 = "474852d6715ddc3b6969e28de5e1a5fbaff9e8ece6aebb9dc1cc63e9e88e89ab";
24 };
25
26 # Patches coming from debian package
27 # https://packages.debian.org/source/sid/libs/libmatheval
28 patches = [
29 (fetchpatch {
30 url = "https://sources.debian.org/data/main/libm/libmatheval/1.1.11%2Bdfsg-5/debian/patches/002-skip-docs.patch";
31 hash = "sha256-wjz54FKQq7t9Bz0W3EOu+ZPTt8EcfkMotkZKwlWa09o=";
32 })
33 (fetchpatch {
34 url = "https://sources.debian.org/data/main/libm/libmatheval/1.1.11%2Bdfsg-5/debian/patches/003-guile3.0.patch";
35 hash = "sha256-H3E/2m4MfQAbjpXbVFyNhikVifi3spVThzaVU5srmjI=";
36 })
37 (fetchpatch {
38 url = "https://sources.debian.org/data/main/libm/libmatheval/1.1.11%2Bdfsg-5/debian/patches/disable_coth_test.patch";
39 hash = "sha256-9XeMXWDTzELWTPcsjAqOlIzp4qY9yupU+e6r0rJEUS0=";
40 })
41 ];
42
43 env.NIX_CFLAGS_COMPILE = "-I${lib.getDev guile}/include/guile/${guile.effectiveVersion}";
44 env.NIX_LDFLAGS = "-L${guile}/lib -lguile-${guile.effectiveVersion}";
45
46 meta = {
47 description = "Library to parse and evaluate symbolic expressions input as text";
48 longDescription = ''
49 GNU libmatheval is a library (callable from C and Fortran) to parse and evaluate symbolic
50 expressions input as text. It supports expressions in any number of variables of arbitrary
51 names, decimal and symbolic constants, basic unary and binary operators, and elementary
52 mathematical functions. In addition to parsing and evaluation, libmatheval can also compute
53 symbolic derivatives and output expressions to strings.
54 '';
55 homepage = "https://www.gnu.org/software/libmatheval/";
56 license = lib.licenses.gpl3;
57 maintainers = [ lib.maintainers.bzizou ];
58 platforms = lib.platforms.unix;
59 };
60}