summary refs log tree commit diff
path: root/pkgs/tools/misc/gringo/default.nix
blob: f08bad03916a3bce02cbda3a2355c743a31891a4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
{ lib, stdenv, fetchurl,
  bison, re2c, sconsPackages,
  libcxx
}:

let
  version = "4.5.4";
in

stdenv.mkDerivation {
  pname = "gringo";
  inherit version;

  src = fetchurl {
    url = "mirror://sourceforge/project/potassco/gringo/${version}/gringo-${version}-source.tar.gz";
    sha256 = "16k4pkwyr2mh5w8j91vhxh9aff7f4y31npwf09w6f8q63fxvpy41";
  };

  buildInputs = [ bison re2c sconsPackages.scons_3_1_2 ];

  patches = [
    ./gringo-4.5.4-cmath.patch
    ./gringo-4.5.4-to_string.patch
  ];

  postPatch = lib.optionalString stdenv.isDarwin ''
    substituteInPlace ./SConstruct \
      --replace \
        "env['CXX']            = 'g++'" \
        "env['CXX']            = '$CXX'"

    substituteInPlace ./SConstruct \
      --replace \
        "env['CPPPATH']        = []" \
        "env['CPPPATH']        = ['${lib.getDev libcxx}/include/c++/v1']"

    substituteInPlace ./SConstruct \
      --replace \
        "env['LIBPATH']        = []" \
        "env['LIBPATH']        = ['${lib.getLib libcxx}/lib']"
  '';

  buildPhase = ''
    scons WITH_PYTHON= --build-dir=release
  '';

  installPhase = ''
    mkdir -p $out/bin
    cp build/release/gringo $out/bin/gringo
  '';

  meta = with lib; {
    description = "Converts input programs with first-order variables to equivalent ground programs";
    homepage = "http://potassco.sourceforge.net/";
    platforms = platforms.all;
    maintainers = [ maintainers.hakuch ];
    license = licenses.gpl3Plus;
  };
}