New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cplex: init at 12.8 #44029
cplex: init at 12.8 #44029
Conversation
nativeBuildInputs = [ coreutils makeWrapper ]; | ||
buildInputs = [ openjdk gtk2 xorg.libXtst glibcLocales ]; | ||
|
||
phases = "installPhase"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't assign phases directly, instead assign the parts of the script the role they have: The first sed
is patchPhase, the sh
buildPhase, put the ln
's in installPhase and the patchelf
/wrapProgram
in fixupPhase.
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:${stdenv.lib.makeLibraryPath [ stdenv.cc.cc gtk2 xorg.libXtst ]} --set LOCALE_ARCHIVE ${glibcLocales}/lib/locale/locale-archive; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use \
to break lines and put a libraryPath = stdenv.lib.makeLibraryPath [ ... ];
definition in a let in
to keep the line length short:
fixupPhase = let libraryPath = ...
in ''
...
wrapProgram $pgm \
--prefix LD_LIBRARY_PATH : $out/opl/bin/x86-64_linux:${libraryPath} \
--set LOCALE_ARCHIVE ${glibcLocales}/lib/locale/locale-archive;
do | ||
if grep ELF $pgm > /dev/null; | ||
then | ||
patchelf --set-interpreter "$interpreter" $pgm; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure patchelf already checks whether it's an ELF binary or not. You could also then merge the patchelf loops.
installer = "cplex_studio${version}.linux-x86-64.bin"; | ||
|
||
src = requireFile rec { | ||
name = "${installer}"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just assign name = "cplex_studio${version}.linux-x86-64.bin";
directly here. And there's no need to use the $installer
variable down below I'd think
@infinisil thanks for the suggestions, indeed the code is much better now. I also changed the source definition, copying from what is done in the renoise build, because the dowloaded archive is likely to be personalized and sha256 check would fail. Note that patchelf fails on non-ELF files. |
nativeBuildInputs = [ coreutils makeWrapper ]; | ||
buildInputs = [ openjdk gtk2 xorg.libXtst glibcLocales ]; | ||
|
||
phases = "patchPhase buildPhase installPhase fixupPhase"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant to remove this line completely, these phases are set like this automatically
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can I disable unpackPhase? I tried to define an empty one, but it did not work (and it complains it does not know how to unpack the cplex bin archive if I do not remove the phase completely).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe unpackPhase = "cp $src ."
will work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cp $src $name
else | ||
releasePath; | ||
|
||
nativeBuildInputs = [ coreutils makeWrapper ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty sure coreutils are present by default, no need to add them here
throw '' | ||
This nix expression requires that the cplex installer is already | ||
downloaded to your machine. Get it from IBM and override the | ||
releasePath attribute to point to the location of the file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add the link to where one can download it in this error message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
phases = "patchPhase buildPhase installPhase fixupPhase"; | ||
|
||
patchPhase = '' | ||
sed -e 's|/usr/bin/tr"|tr" |' $src > $name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use sed -i
to modify the file inplace, no need to > $name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But $src is the original file, I don't want to modify that one. (The other option would be to first copy the file in the unpack phase...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the cp in the unpackPhase, sed -i does the job. (BTW, I did not use the builtin substituteInPlace because it is way too slow on such a large file).
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 | ||
ln -s $pgm $out/bin; | ||
done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can make this a single command and use some newlines:
ln -s $out/opl/bin/x86-64_linux/oplrun \
$out/opl/bin/x86-64_linux/oplrunjava \
... \
$out/bin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -0,0 +1,75 @@ | |||
{ stdenv, coreutils, requireFile, patchelf, makeWrapper, openjdk, gtk2, xorg, glibcLocales, releasePath ? null }: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can remove patchelf
, coreutils
and requireFile
from here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the long review process, I hope you don't mind! I asked around, and apparently some people are against including derivations that need such special ways of fetching sources: #13625. I think it's alright for this one though :)
@@ -0,0 +1,81 @@ | |||
{ stdenv, makeWrapper, openjdk, gtk2, xorg, glibcLocales, releasePath ? null }: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternate suggestion I think I'd prefer: Use the config
attribute here instead, and use config.cplex.releasePath
to get the path. Then users using nix-env will have it easy to make it work, it just needs a { cplex.releasePath = ...; }
in their ~/.config/nixpkgs/config.nix
. This could then also be documented in the error message: "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 ..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to apologize, I appreciate the feedback as I am quite a newbie here, and is good to have some mentoring. I like the config idea, it should also be ported to renoise to imho (I inspired myself from the renoise build for this one).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here it is. I hope I did it the right way...
Thanks! The only thing left to do is squash all commits into one |
Motivation for this change
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)