aboutsummaryrefslogtreecommitdiff
path: root/conjure/solvers.nix
blob: fd576a785bb47d521e66ebba984b7e8e6486cf89 (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
60
61
62
63
64
65
66
67
68
69
70
{ stdenv
, fetchurl
, lib
, unzip
, callPackage

, savilerow

, ...
}:

let
  mkSolverDerivation = { pname, version ? "unknown", libs ? [], static ? false, ... }@info: stdenv.mkDerivation (rec {
    inherit pname version;

    buildInputs = [ unzip ];

    src = fetchurl {
      url = https://github.com/conjure-cp/conjure/releases/download/v2.3.0/conjure-v2.3.0-linux-solvers.zip;
      sha256 = "09ajj7zbb4rk9srk3q9gmfkvaymwsd8ai3ddkkinp8y8z018abk0";
    };

    libPath = lib.makeLibraryPath libs;

    installPhase = ''
      mkdir -p $out/bin
      cp ./${pname} $out/bin/${pname}

      ${if static then "" else ''
      patchelf \
        --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
        --set-rpath "${libPath}" \
        $out/bin/${pname}
      ''}

    '';

  } // info);

  double = { text }: y: text + y;

  addNewSolverDerivation = o: info:
    let
      sdv = mkSolverDerivation info;
    in
      o // { ${sdv.name} = sdv; };

  obj = builtins.foldl' addNewSolverDerivation {};

  addSavileRow = { minion-2, ... }@solvers: solvers // ({
    savilerow = (savilerow.overrideAttrs (old: {
      version = "1.7.0";
      buildInputs = [ unzip ];

      # minion is picked here but it could be any of the solvers
      src = minion-2.src;
    })).override { minion = minion-2; };
  });

in with pkgs; addSavileRow (obj [
  { pname = "bc_minisat_all_release"; libs = [ zlib ]; }
  { pname = "fzn-chuffed"; libs = [ stdenv.cc.cc ]; dontStrip = true; }
  { pname = "fzn-gecode"; libs = [ stdenv.cc.cc ]; dontStrip = true; }
  { pname = "glucose"; libs = [ zlib ]; }
  { pname = "glucose-syrup"; libs = [ zlib ]; }
  { pname = "lingeling"; }
  { pname = "nbc_minisat_all_release"; libs = [ zlib ]; }
  { pname = "minion"; version = "2"; static = true; }
  { pname = "open-wbo"; libs = [ zlib stdenv.cc.cc gmp gmpxx ]; dontStrip = true; }
])