From 1c4001f9cbb52de31412ab52b3951551a4ae007e Mon Sep 17 00:00:00 2001 From: Marco Rebhan Date: Mon, 2 Dec 2024 14:23:04 +0100 Subject: [PATCH 1/9] cplex: set meta.mainProgram --- pkgs/applications/science/math/cplex/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/applications/science/math/cplex/default.nix b/pkgs/applications/science/math/cplex/default.nix index e80444b70b27..bdb8afb9dc02 100644 --- a/pkgs/applications/science/math/cplex/default.nix +++ b/pkgs/applications/science/math/cplex/default.nix @@ -81,6 +81,7 @@ stdenv.mkDerivation rec { meta = with lib; { description = "Optimization solver for mathematical programming"; homepage = "https://www.ibm.com/be-en/marketplace/ibm-ilog-cplex"; + mainProgram = "cplex"; sourceProvenance = with sourceTypes; [ binaryNativeCode ]; license = licenses.unfree; platforms = [ "x86_64-linux" ]; From 1f75f5cd8092b6dd7216be9dd5d2793e99e5d0b5 Mon Sep 17 00:00:00 2001 From: Marco Rebhan Date: Mon, 2 Dec 2024 14:23:04 +0100 Subject: [PATCH 2/9] cplex: fix phase hooks --- pkgs/applications/science/math/cplex/default.nix | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pkgs/applications/science/math/cplex/default.nix b/pkgs/applications/science/math/cplex/default.nix index bdb8afb9dc02..9b0bbcfdd244 100644 --- a/pkgs/applications/science/math/cplex/default.nix +++ b/pkgs/applications/science/math/cplex/default.nix @@ -31,16 +31,22 @@ stdenv.mkDerivation rec { unpackPhase = "cp $src $name"; - patchPhase = '' + postPatch = '' sed -i -e 's|/usr/bin/tr"|tr" |' $name ''; buildPhase = '' + runHook preBuild + export JAVA_TOOL_OPTIONS=-Djdk.util.zip.disableZip64ExtraFieldValidation=true sh $name LAX_VM ${openjdk}/bin/java -i silent -DLICENSE_ACCEPTED=TRUE -DUSER_INSTALL_DIR=$out + + runHook postBuild ''; installPhase = '' + runHook preInstall + mkdir -p $out/bin ln -s $out/opl/bin/x86-64_linux/oplrun\ $out/opl/bin/x86-64_linux/oplrunjava\ @@ -48,12 +54,16 @@ stdenv.mkDerivation rec { $out/cplex/bin/x86-64_linux/cplex\ $out/cpoptimizer/bin/x86-64_linux/cpoptimizer\ $out/bin + + runHook postInstall ''; fixupPhase = let libraryPath = lib.makeLibraryPath [ stdenv.cc.cc gtk2 xorg.libXtst ]; in '' + runHook preFixup + interpreter=${stdenv.cc.libc}/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; @@ -71,6 +81,8 @@ stdenv.mkDerivation rec { patchelf --set-interpreter "$interpreter" $pgm; fi done + + runHook postFixup ''; passthru = { From b48264149acecc5b4e43679d0c758f70e874c387 Mon Sep 17 00:00:00 2001 From: Marco Rebhan Date: Mon, 2 Dec 2024 14:23:04 +0100 Subject: [PATCH 3/9] cplex: move doc and license to share, remove uninstall dir --- pkgs/applications/science/math/cplex/default.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkgs/applications/science/math/cplex/default.nix b/pkgs/applications/science/math/cplex/default.nix index 9b0bbcfdd244..27568cdb2144 100644 --- a/pkgs/applications/science/math/cplex/default.nix +++ b/pkgs/applications/science/math/cplex/default.nix @@ -55,6 +55,12 @@ stdenv.mkDerivation rec { $out/cpoptimizer/bin/x86-64_linux/cpoptimizer\ $out/bin + mkdir -p $out/share/doc + mv $out/doc $out/share/doc/$name + + mkdir -p $out/share/licenses + mv $out/license $out/share/licenses/$name + runHook postInstall ''; @@ -64,6 +70,8 @@ stdenv.mkDerivation rec { in '' runHook preFixup + rm -r $out/Uninstall + interpreter=${stdenv.cc.libc}/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; From e5e587880922d00fa025d5b1d13f3fd55577ba9c Mon Sep 17 00:00:00 2001 From: Marco Rebhan Date: Mon, 2 Dec 2024 14:23:04 +0100 Subject: [PATCH 4/9] cplex: install desktop entry --- .../science/math/cplex/default.nix | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/pkgs/applications/science/math/cplex/default.nix b/pkgs/applications/science/math/cplex/default.nix index 27568cdb2144..01309b6db7c3 100644 --- a/pkgs/applications/science/math/cplex/default.nix +++ b/pkgs/applications/science/math/cplex/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, makeWrapper, openjdk, gtk2, xorg, glibcLocales, releasePath ? null }: +{ lib, stdenv, makeDesktopItem, copyDesktopItems, makeWrapper, openjdk, gtk2, xorg, glibcLocales, releasePath ? null }: # 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. @@ -26,7 +26,7 @@ stdenv.mkDerivation rec { else releasePath; - nativeBuildInputs = [ makeWrapper ]; + nativeBuildInputs = [ copyDesktopItems makeWrapper ]; buildInputs = [ openjdk gtk2 xorg.libXtst glibcLocales ]; unpackPhase = "cp $src $name"; @@ -55,6 +55,9 @@ stdenv.mkDerivation rec { $out/cpoptimizer/bin/x86-64_linux/cpoptimizer\ $out/bin + mkdir -p $out/share/pixmaps + ln -s $out/opl/oplide/icon.xpm $out/share/pixmaps/oplide.xpm + mkdir -p $out/share/doc mv $out/doc $out/share/doc/$name @@ -64,6 +67,17 @@ stdenv.mkDerivation rec { runHook postInstall ''; + desktopItems = [ + (makeDesktopItem { + name = "oplide"; + desktopName = "IBM ILOG CPLEX Optimization Studio"; + genericName = "Optimization Software"; + icon = "oplide"; + exec = "oplide"; + categories = [ "Development" "IDE" "Math" "Science" ]; + }) + ]; + fixupPhase = let libraryPath = lib.makeLibraryPath [ stdenv.cc.cc gtk2 xorg.libXtst ]; From 9351aae45269f888708711d25e2fd8e60a7a7e7c Mon Sep 17 00:00:00 2001 From: Marco Rebhan Date: Mon, 2 Dec 2024 16:49:12 +0100 Subject: [PATCH 5/9] cplex: put openjdk in nativeBuildInputs --- pkgs/applications/science/math/cplex/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/applications/science/math/cplex/default.nix b/pkgs/applications/science/math/cplex/default.nix index 01309b6db7c3..70f5cbbb266a 100644 --- a/pkgs/applications/science/math/cplex/default.nix +++ b/pkgs/applications/science/math/cplex/default.nix @@ -26,8 +26,8 @@ stdenv.mkDerivation rec { else releasePath; - nativeBuildInputs = [ copyDesktopItems makeWrapper ]; - buildInputs = [ openjdk gtk2 xorg.libXtst glibcLocales ]; + nativeBuildInputs = [ copyDesktopItems makeWrapper openjdk ]; + buildInputs = [ gtk2 xorg.libXtst glibcLocales ]; unpackPhase = "cp $src $name"; @@ -39,7 +39,7 @@ stdenv.mkDerivation rec { runHook preBuild export JAVA_TOOL_OPTIONS=-Djdk.util.zip.disableZip64ExtraFieldValidation=true - sh $name LAX_VM ${openjdk}/bin/java -i silent -DLICENSE_ACCEPTED=TRUE -DUSER_INSTALL_DIR=$out + sh $name LAX_VM "$(command -v java)" -i silent -DLICENSE_ACCEPTED=TRUE -DUSER_INSTALL_DIR=$out runHook postBuild ''; From a4f8586a70208c5c579d80dea03910f91771bd86 Mon Sep 17 00:00:00 2001 From: Marco Rebhan Date: Mon, 2 Dec 2024 15:23:04 +0100 Subject: [PATCH 6/9] cplex: use autoPatchelfHook --- .../applications/science/math/cplex/default.nix | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/pkgs/applications/science/math/cplex/default.nix b/pkgs/applications/science/math/cplex/default.nix index 70f5cbbb266a..1293a3235e3c 100644 --- a/pkgs/applications/science/math/cplex/default.nix +++ b/pkgs/applications/science/math/cplex/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, makeDesktopItem, copyDesktopItems, makeWrapper, openjdk, gtk2, xorg, glibcLocales, releasePath ? null }: +{ lib, stdenv, autoPatchelfHook, makeDesktopItem, copyDesktopItems, makeWrapper, alsa-lib, openjdk, sqlite, unixODBC, gtk2, xorg, glibcLocales, releasePath ? null }: # 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. @@ -26,8 +26,8 @@ stdenv.mkDerivation rec { else releasePath; - nativeBuildInputs = [ copyDesktopItems makeWrapper openjdk ]; - buildInputs = [ gtk2 xorg.libXtst glibcLocales ]; + nativeBuildInputs = [ autoPatchelfHook copyDesktopItems makeWrapper openjdk ]; + buildInputs = [ alsa-lib gtk2 sqlite unixODBC xorg.libXtst glibcLocales ]; unpackPhase = "cp $src $name"; @@ -86,24 +86,13 @@ stdenv.mkDerivation rec { rm -r $out/Uninstall - interpreter=${stdenv.cc.libc}/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 - runHook postFixup ''; From 7c3295abd5bcce3fd9570d59dbd64898bbb5826c Mon Sep 17 00:00:00 2001 From: Marco Rebhan Date: Mon, 2 Dec 2024 17:12:04 +0100 Subject: [PATCH 7/9] cplex: use makeWrapper instead of wrapProgram --- .../science/math/cplex/default.nix | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/pkgs/applications/science/math/cplex/default.nix b/pkgs/applications/science/math/cplex/default.nix index 1293a3235e3c..0a209560e9f5 100644 --- a/pkgs/applications/science/math/cplex/default.nix +++ b/pkgs/applications/science/math/cplex/default.nix @@ -48,12 +48,17 @@ stdenv.mkDerivation rec { runHook preInstall 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 + + for pgm in \ + $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 + do + makeWrapper "$pgm" "$out/bin/$(basename "$pgm")" \ + --set-default LOCALE_ARCHIVE ${glibcLocales}/lib/locale/locale-archive + done mkdir -p $out/share/pixmaps ln -s $out/opl/oplide/icon.xpm $out/share/pixmaps/oplide.xpm @@ -78,21 +83,11 @@ stdenv.mkDerivation rec { }) ]; - fixupPhase = - let - libraryPath = lib.makeLibraryPath [ stdenv.cc.cc gtk2 xorg.libXtst ]; - in '' + fixupPhase = '' runHook preFixup rm -r $out/Uninstall - for pgm in $out/opl/bin/x86-64_linux/oplrun $out/opl/bin/x86-64_linux/oplrunjava $out/opl/oplide/oplide; - do - wrapProgram $pgm \ - --prefix LD_LIBRARY_PATH : $out/opl/bin/x86-64_linux:${libraryPath} \ - --set LOCALE_ARCHIVE ${glibcLocales}/lib/locale/locale-archive; - done - runHook postFixup ''; From 2df4affe417a3a822fc7688f925c766a9aa1d7bc Mon Sep 17 00:00:00 2001 From: Marco Rebhan Date: Mon, 2 Dec 2024 15:23:04 +0100 Subject: [PATCH 8/9] cplex: fix oplide --- .../science/math/cplex/default.nix | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/pkgs/applications/science/math/cplex/default.nix b/pkgs/applications/science/math/cplex/default.nix index 0a209560e9f5..d0fb7dfb73fd 100644 --- a/pkgs/applications/science/math/cplex/default.nix +++ b/pkgs/applications/science/math/cplex/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, autoPatchelfHook, makeDesktopItem, copyDesktopItems, makeWrapper, alsa-lib, openjdk, sqlite, unixODBC, gtk2, xorg, glibcLocales, releasePath ? null }: +{ lib, stdenv, autoPatchelfHook, makeDesktopItem, copyDesktopItems, makeWrapper, alsa-lib, glib, glib-networking, gsettings-desktop-schemas, gtk3, libsecret, openjdk, sqlite, unixODBC, gtk2, xorg, glibcLocales, releasePath ? null }: # 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. @@ -27,7 +27,7 @@ stdenv.mkDerivation rec { releasePath; nativeBuildInputs = [ autoPatchelfHook copyDesktopItems makeWrapper openjdk ]; - buildInputs = [ alsa-lib gtk2 sqlite unixODBC xorg.libXtst glibcLocales ]; + buildInputs = [ alsa-lib gsettings-desktop-schemas gtk2 sqlite unixODBC xorg.libXtst glibcLocales ]; unpackPhase = "cp $src $name"; @@ -44,7 +44,9 @@ stdenv.mkDerivation rec { runHook postBuild ''; - installPhase = '' + installPhase = let + libraryPath = lib.makeLibraryPath [ stdenv.cc.cc glib gtk2 gtk3 libsecret xorg.libXtst ]; + in '' runHook preInstall mkdir -p $out/bin @@ -56,8 +58,19 @@ stdenv.mkDerivation rec { $out/cplex/bin/x86-64_linux/cplex \ $out/cpoptimizer/bin/x86-64_linux/cpoptimizer do - makeWrapper "$pgm" "$out/bin/$(basename "$pgm")" \ + makeWrapperArgs=( --set-default LOCALE_ARCHIVE ${glibcLocales}/lib/locale/locale-archive + ) + + if [[ "$pgm" = "$out/opl/oplide/oplide" ]]; then + makeWrapperArgs+=( + --prefix LD_LIBRARY_PATH : ${libraryPath} + --prefix GIO_EXTRA_MODULES : "${glib-networking}/lib/gio/modules" + --prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH" + ) + fi + + makeWrapper "$pgm" "$out/bin/$(basename "$pgm")" "''${makeWrapperArgs[@]}" done mkdir -p $out/share/pixmaps From e7db63fb2c1188bb0ad99040a28380662f185573 Mon Sep 17 00:00:00 2001 From: Marco Rebhan Date: Mon, 2 Dec 2024 14:23:04 +0100 Subject: [PATCH 9/9] cplex: fix file permissions --- pkgs/applications/science/math/cplex/default.nix | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pkgs/applications/science/math/cplex/default.nix b/pkgs/applications/science/math/cplex/default.nix index d0fb7dfb73fd..9e2fca3ad3ed 100644 --- a/pkgs/applications/science/math/cplex/default.nix +++ b/pkgs/applications/science/math/cplex/default.nix @@ -101,6 +101,21 @@ stdenv.mkDerivation rec { rm -r $out/Uninstall + bins=( + $out/bin/* + $out/cplex/bin/x86-64_linux/cplex + $out/cplex/bin/x86-64_linux/cplexamp + $out/cpoptimizer/bin/x86-64_linux/cpoptimizer + $out/opl/bin/x86-64_linux/oplrun + $out/opl/bin/x86-64_linux/oplrunjava + $out/opl/oplide/jre/bin/* + $out/opl/oplide/oplide + ) + + find $out -type d -exec chmod 755 {} \; + find $out -type f -exec chmod 644 {} \; + chmod +111 "''${bins[@]}" + runHook postFixup '';