summary refs log tree commit diff
diff options
context:
space:
mode:
authorBernard Fortz <bernard.fortz@gmail.com>2018-08-16 02:46:09 +0200
committerMatthew Bauer <mjbauer95@gmail.com>2018-08-15 19:46:09 -0500
commit22c15abe2073084025ad70ab58e39ee36e1e4d21 (patch)
tree515f5af76c31e27eed6bca07a3f892a8eb7c4534
parentbbb0e5332b440c02c28d643e41edffa2fa9db7ea (diff)
downloadnixpkgs-22c15abe2073084025ad70ab58e39ee36e1e4d21.tar
nixpkgs-22c15abe2073084025ad70ab58e39ee36e1e4d21.tar.gz
nixpkgs-22c15abe2073084025ad70ab58e39ee36e1e4d21.tar.bz2
nixpkgs-22c15abe2073084025ad70ab58e39ee36e1e4d21.tar.lz
nixpkgs-22c15abe2073084025ad70ab58e39ee36e1e4d21.tar.xz
nixpkgs-22c15abe2073084025ad70ab58e39ee36e1e4d21.tar.zst
nixpkgs-22c15abe2073084025ad70ab58e39ee36e1e4d21.zip
cplex: init at 12.8 (#44029)
* cplex: init at 12.8

* Removed bundled java from bin directory

* Refactored

* More refactoring

* Added config option for releasePath

* Minor cleanup
-rw-r--r--pkgs/applications/science/math/cplex/default.nix82
-rw-r--r--pkgs/top-level/all-packages.nix2
2 files changed, 84 insertions, 0 deletions
diff --git a/pkgs/applications/science/math/cplex/default.nix b/pkgs/applications/science/math/cplex/default.nix
new file mode 100644
index 00000000000..fe3913648f8
--- /dev/null
+++ b/pkgs/applications/science/math/cplex/default.nix
@@ -0,0 +1,82 @@
+{ stdenv, makeWrapper, openjdk, gtk2, xorg, glibcLocales, releasePath }:
+
+# To use this package, you need to download your own cplex installer from IBM
+# and override the releasePath attribute to point to the location of the file.  
+#
+# Note: cplex creates an individual build for each license which screws
+# somewhat with the use of functions like requireFile as the hash will be
+# different for every user.
+
+stdenv.mkDerivation rec {
+  name = "cplex-${version}";
+  version = "128";
+  
+  src =
+    if builtins.isNull releasePath then
+      throw ''
+        This nix expression requires that the cplex installer is already
+        downloaded to your machine. Get it from IBM: 
+        https://developer.ibm.com/docloud/blog/2017/12/20/cplex-optimization-studio-12-8-now-available/ 
+
+        Set `cplex.releasePath = /path/to/download;` in your
+        ~/.config/nixpkgs/config.nix for `nix-*` commands, or
+        `config.cplex.releasePath = /path/to/download;` in your
+        `configuration.nix` for NixOS.
+      ''
+    else
+      releasePath;
+
+  nativeBuildInputs = [ makeWrapper ];
+  buildInputs = [ openjdk gtk2 xorg.libXtst glibcLocales ];
+
+  unpackPhase = "cp $src $name";
+
+  patchPhase = ''
+    sed -i -e 's|/usr/bin/tr"|tr"         |' $name
+  '';
+
+  buildPhase = ''
+    sh $name -i silent -DLICENSE_ACCEPTED=TRUE -DUSER_INSTALL_DIR=$out
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    ln -s $out/opl/bin/x86-64_linux/oplrun\
+      $out/opl/bin/x86-64_linux/oplrunjava\
+      $out/opl/oplide/oplide\
+      $out/cplex/bin/x86-64_linux/cplex\
+      $out/cpoptimizer/bin/x86-64_linux/cpoptimizer\
+      $out/bin
+  '';
+
+  fixupPhase = 
+  let 
+    libraryPath = stdenv.lib.makeLibraryPath [ stdenv.cc.cc gtk2 xorg.libXtst ];
+  in ''
+    interpreter=${stdenv.glibc}/lib/ld-linux-x86-64.so.2
+
+    for pgm in $out/opl/bin/x86-64_linux/oplrun $out/opl/bin/x86-64_linux/oplrunjava $out/opl/oplide/oplide;
+    do
+      patchelf --set-interpreter "$interpreter" $pgm;
+      wrapProgram $pgm \
+        --prefix LD_LIBRARY_PATH : $out/opl/bin/x86-64_linux:${libraryPath} \
+        --set LOCALE_ARCHIVE ${glibcLocales}/lib/locale/locale-archive;
+    done
+
+    for pgm in $out/cplex/bin/x86-64_linux/cplex $out/cpoptimizer/bin/x86-64_linux/cpoptimizer $out/opl/oplide/jre/bin/*; 
+    do
+      if grep ELF $pgm > /dev/null;
+      then
+        patchelf --set-interpreter "$interpreter" $pgm;
+      fi
+    done
+  '';
+  
+  meta = with stdenv.lib; {
+    description = "Optimization solver for mathematical programming";
+    homepage = "https://www.ibm.com/be-en/marketplace/ibm-ilog-cplex";
+    license = licenses.unfree;
+    platforms = [ "x86_64-linux" ];
+    maintainers = with maintainers; [ bfortz ];
+  };
+}
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 53378170716..cf4ba4d1c4d 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -1117,6 +1117,8 @@ with pkgs;
     flex = flex_2_5_35;
   };
 
+  cplex = callPackage ../applications/science/math/cplex { releasePath = config.cplex.releasePath or null; };
+
   cpulimit = callPackage ../tools/misc/cpulimit { };
 
   codesearch = callPackage ../tools/text/codesearch { };