2013-09-15 13:22:27 +01:00
|
|
|
{ stdenv
|
|
|
|
, coreutils
|
|
|
|
, patchelf
|
|
|
|
, requireFile
|
|
|
|
, alsaLib
|
|
|
|
, fontconfig
|
|
|
|
, freetype
|
|
|
|
, gcc
|
|
|
|
, glib
|
|
|
|
, libpng
|
|
|
|
, ncurses
|
|
|
|
, opencv
|
|
|
|
, openssl
|
|
|
|
, unixODBC
|
2015-09-15 10:26:18 +01:00
|
|
|
, xorg
|
2013-09-15 13:22:27 +01:00
|
|
|
, zlib
|
2014-09-17 22:25:10 +01:00
|
|
|
, libxml2
|
|
|
|
, libuuid
|
2013-09-15 13:22:27 +01:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
platform =
|
2013-11-02 17:05:16 +00:00
|
|
|
if stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux" then
|
2013-09-15 13:22:27 +01:00
|
|
|
"Linux"
|
|
|
|
else
|
2013-10-01 12:12:10 +01:00
|
|
|
throw "Mathematica requires i686-linux or x86_64 linux";
|
2013-09-15 13:22:27 +01:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
2016-11-23 15:54:06 +00:00
|
|
|
version = "11.0.1";
|
2013-09-15 13:22:27 +01:00
|
|
|
|
2014-09-17 22:25:10 +01:00
|
|
|
name = "mathematica-${version}";
|
2013-09-15 13:22:27 +01:00
|
|
|
|
|
|
|
src = requireFile rec {
|
2014-09-17 22:25:10 +01:00
|
|
|
name = "Mathematica_${version}_LINUX.sh";
|
2013-09-15 13:22:27 +01:00
|
|
|
message = ''
|
2014-09-17 22:25:10 +01:00
|
|
|
This nix expression requires that ${name} is
|
2013-09-15 13:22:27 +01:00
|
|
|
already part of the store. Find the file on your Mathematica CD
|
|
|
|
and add it to the nix store with nix-store --add-fixed sha256 <FILE>.
|
|
|
|
'';
|
2016-11-23 15:54:06 +00:00
|
|
|
sha256 = "1qqwz8gbw74rnnyirpbdanwx3d25s4x0i4zc7bs6kp959x66cdkw";
|
2013-09-15 13:22:27 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
coreutils
|
|
|
|
patchelf
|
|
|
|
alsaLib
|
|
|
|
coreutils
|
|
|
|
fontconfig
|
|
|
|
freetype
|
2015-01-15 04:44:00 +00:00
|
|
|
gcc.cc
|
2013-09-15 13:22:27 +01:00
|
|
|
gcc.libc
|
|
|
|
glib
|
|
|
|
ncurses
|
|
|
|
opencv
|
|
|
|
openssl
|
|
|
|
unixODBC
|
2014-09-17 22:25:10 +01:00
|
|
|
libxml2
|
|
|
|
libuuid
|
2015-09-15 10:26:18 +01:00
|
|
|
] ++ (with xorg; [
|
2013-09-15 13:22:27 +01:00
|
|
|
libX11
|
|
|
|
libXext
|
|
|
|
libXtst
|
|
|
|
libXi
|
|
|
|
libXmu
|
|
|
|
libXrender
|
|
|
|
libxcb
|
2014-09-17 22:25:10 +01:00
|
|
|
libXcursor
|
|
|
|
libXfixes
|
|
|
|
libXrandr
|
|
|
|
libICE
|
|
|
|
libSM
|
2013-09-15 13:22:27 +01:00
|
|
|
]);
|
|
|
|
|
|
|
|
ldpath = stdenv.lib.makeLibraryPath buildInputs
|
|
|
|
+ stdenv.lib.optionalString (stdenv.system == "x86_64-linux")
|
2016-04-14 16:14:28 +01:00
|
|
|
(":" + stdenv.lib.makeSearchPathOutput "lib" "lib64" buildInputs);
|
2013-09-15 13:22:27 +01:00
|
|
|
|
|
|
|
phases = "unpackPhase installPhase fixupPhase";
|
|
|
|
|
|
|
|
unpackPhase = ''
|
|
|
|
echo "=== Extracting makeself archive ==="
|
|
|
|
# find offset from file
|
|
|
|
offset=$(${stdenv.shell} -c "$(grep -axm1 -e 'offset=.*' $src); echo \$offset" $src)
|
|
|
|
dd if="$src" ibs=$offset skip=1 | tar -xf -
|
|
|
|
cd Unix
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
cd Installer
|
|
|
|
# don't restrict PATH, that has already been done
|
|
|
|
sed -i -e 's/^PATH=/# PATH=/' MathInstaller
|
2016-11-23 15:54:06 +00:00
|
|
|
sed -i -e 's/\/bin\/bash/\/bin\/sh/' MathInstaller
|
2013-09-15 13:22:27 +01:00
|
|
|
|
|
|
|
echo "=== Running MathInstaller ==="
|
2016-11-23 15:54:06 +00:00
|
|
|
./MathInstaller -auto -createdir=y -execdir=$out/bin -targetdir=$out/libexec/Mathematica -silent
|
2013-09-15 13:22:27 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
preFixup = ''
|
|
|
|
echo "=== PatchElfing away ==="
|
2015-11-30 20:07:26 +00:00
|
|
|
# This code should be a bit forgiving of errors, unfortunately
|
|
|
|
set +e
|
2015-09-06 09:21:43 +01:00
|
|
|
find $out/libexec/Mathematica/SystemFiles -type f -perm -0100 | while read f; do
|
2013-09-15 13:22:27 +01:00
|
|
|
type=$(readelf -h "$f" 2>/dev/null | grep 'Type:' | sed -e 's/ *Type: *\([A-Z]*\) (.*/\1/')
|
|
|
|
if [ -z "$type" ]; then
|
|
|
|
:
|
|
|
|
elif [ "$type" == "EXEC" ]; then
|
|
|
|
echo "patching $f executable <<"
|
|
|
|
patchelf --shrink-rpath "$f"
|
2014-09-17 22:25:10 +01:00
|
|
|
patchelf \
|
2014-12-17 18:11:30 +00:00
|
|
|
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
2014-09-17 22:25:10 +01:00
|
|
|
--set-rpath "$(patchelf --print-rpath "$f"):${ldpath}" \
|
|
|
|
"$f" \
|
|
|
|
&& patchelf --shrink-rpath "$f" \
|
|
|
|
|| echo unable to patch ... ignoring 1>&2
|
2013-09-15 13:22:27 +01:00
|
|
|
elif [ "$type" == "DYN" ]; then
|
|
|
|
echo "patching $f library <<"
|
|
|
|
patchelf \
|
|
|
|
--set-rpath "$(patchelf --print-rpath "$f"):${ldpath}" \
|
|
|
|
"$f" \
|
|
|
|
&& patchelf --shrink-rpath "$f" \
|
|
|
|
|| echo unable to patch ... ignoring 1>&2
|
|
|
|
else
|
|
|
|
echo "not patching $f <<: unknown elf type"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
|
|
|
# all binaries are already stripped
|
|
|
|
dontStrip = true;
|
|
|
|
|
|
|
|
# we did this in prefixup already
|
|
|
|
dontPatchELF = true;
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "Wolfram Mathematica computational software system";
|
|
|
|
homepage = "http://www.wolfram.com/mathematica/";
|
2014-06-19 05:19:00 +01:00
|
|
|
license = stdenv.lib.licenses.unfree;
|
2013-09-15 13:22:27 +01:00
|
|
|
};
|
|
|
|
}
|