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