From 2c2c10d552e818d0f2afadeca0169429052a984f Mon Sep 17 00:00:00 2001 From: Tom Harley Date: Sat, 28 Nov 2020 12:18:41 +0000 Subject: Create operational Conjure The derivation described in `conjure-minion.nix` creates a functional Conjure/Savile Row/Minion setup, where `conjure solve` can succesfully solve using Savile Row and Minion. Unfortunately, the most recent versions of these three programs available on their respective download pages do not cooperate. As of this commit, Minion v2 is not available on its download site https://constraintmodelling.org/minion/download/ but it is available in Conjure's downloads https://github.com/conjure-cp/conjure/releases/tag/v2.3.0 along with Savile Row v1.7.0. These three programs work together, and as such are the ones mentioned in `conjure-minion.nix`. Additionally, the property `conjure.containedSolvers` on `default.nix` contains derivations able to build the solvers provided on the Conjure download page. This shows an issue which is not solved by nixpgks: dependencies on specific versions/version ranges. nixpkgs does not really support referring to specific versions of packages: https://github.com/NixOS/nixpkgs/issues/93327 support for version dependencies seems unlikely to appear soon. Having multiple different versions of packages available and using a CI test system to check for support in a matrix of different package versions could be a nice thing to implement---then again, it could also end up being a waste of CPU (and human) time. --- conjure/default.nix | 13 +++++++------ conjure/solvers.nix | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 6 deletions(-) create mode 100644 conjure/solvers.nix (limited to 'conjure') diff --git a/conjure/default.nix b/conjure/default.nix index aa88dbb..16628f2 100644 --- a/conjure/default.nix +++ b/conjure/default.nix @@ -10,22 +10,21 @@ in , fetchurl ? pkgs.fetchurl , makeWrapper ? pkgs.makeWrapper , savilerow ? pkgs.callPackage ../savilerow {} - , minion ? pkgs.callPackage ../minion {} , includeSolver ? true }: - stdenv.mkDerivation rec { - pname = "conjure"; + (stdenv.mkDerivation rec { + name = "conjure"; version = "2.3.0"; - buildInputs = [ patchelf unzip makeWrapper ]; + buildInputs = [ unzip makeWrapper ]; libPath = lib.makeLibraryPath [ gmp ]; binPath = if includeSolver - then lib.makeBinPath [ savilerow minion ] + then lib.makeBinPath [ savilerow savilerow.minion ] else ""; src = fetchurl { - url = "https://github.com/conjure-cp/conjure/releases/download/v${version}/${pname}-v${version}-linux.zip"; + url = "https://github.com/conjure-cp/conjure/releases/download/v${version}/${name}-v${version}-linux.zip"; sha256 = "cffa971f45438e0c2655d3546d61dc314dfdf05e8daf31d280131d515fc41f0e"; }; @@ -43,4 +42,6 @@ in ''; dontStrip = true; + }) // { + containedSolvers = import ./solvers.nix {}; } diff --git a/conjure/solvers.nix b/conjure/solvers.nix new file mode 100644 index 0000000..3528c81 --- /dev/null +++ b/conjure/solvers.nix @@ -0,0 +1,56 @@ +let pkgs = import {}; in + +{ stdenv ? pkgs.stdenv +, fetchurl ? pkgs.fetchurl +, lib ? pkgs.lib +, unzip ? pkgs.unzip +, main_savilerow ? pkgs.callPackage ../savilerow {} +}: + +let + mkSolverDerivation = { name, libs ? [], static ? false, ... }@info: stdenv.mkDerivation (rec { + 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 ./${name} $out/bin/${name} + + ${if static then "" else '' + patchelf \ + --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ + --set-rpath "${libPath}" \ + $out/bin/${name} + ''} + + ''; + + } // info); + + obj = builtins.foldl' (o: { name, ... }@info: o // { ${name} = mkSolverDerivation info; }) {}; + + addSavileRow = { minion, ... }@solvers: solvers // ({ + savilerow = (main_savilerow.overrideAttrs (old: { + buildInputs = [ unzip ]; + + src = solvers.minion.src; + })).override { minion = solvers.minion; }; + }); + +in with pkgs; addSavileRow (obj [ + { name = "bc_minisat_all_release"; libs = [ zlib ]; } + { name = "fzn-chuffed"; libs = [ stdenv.cc.cc ]; dontStrip = true; } + { name = "fzn-gecode"; libs = [ stdenv.cc.cc ]; dontStrip = true; } + { name = "glucose"; libs = [ zlib ]; } + { name = "glucose-syrup"; libs = [ zlib ]; } + { name = "lingeling"; } + { name = "nbc_minisat_all_release"; libs = [ zlib ]; } + { name = "minion"; static = true; } + { name = "open-wbo"; libs = [ zlib stdenv.cc.cc gmp gmpxx ]; dontStrip = true; } +]) -- cgit v1.2.1