Mathematica: refactored (#172136)

main
Guanpeng Xu 2 years ago committed by GitHub
parent 6925d06dd1
commit cefda1c7ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 37
      pkgs/applications/science/math/mathematica/10.nix
  2. 41
      pkgs/applications/science/math/mathematica/11.nix
  3. 32
      pkgs/applications/science/math/mathematica/9.nix
  4. 209
      pkgs/applications/science/math/mathematica/default.nix
  5. 192
      pkgs/applications/science/math/mathematica/generic.nix
  6. 106
      pkgs/applications/science/math/mathematica/l10ns.nix
  7. 103
      pkgs/applications/science/math/mathematica/versions.nix
  8. 19
      pkgs/top-level/all-packages.nix

@ -1,19 +1,30 @@
{ lib, stdenv
, coreutils
{ lib
, patchelf
, requireFile
, stdenv
# arguments from default.nix
, lang
, meta
, name
, src
, version
# dependencies
, alsa-lib
, coreutils
, cudaPackages
, fontconfig
, freetype
, gcc
, glib
, libuuid
, libxml2
, ncurses
, opencv2
, openssl
, unixODBC
, xorg
, libxml2
, libuuid
# options
, cudaSupport
}:
let
@ -24,20 +35,10 @@ let
throw "Mathematica requires i686-linux or x86_64 linux";
in
stdenv.mkDerivation rec {
version = "10.0.2";
inherit meta src version;
pname = "mathematica";
src = requireFile rec {
name = "Mathematica_${version}_LINUX.sh";
message = ''
This nix expression requires that ${name} is
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>.
'';
sha256 = "1d2yaiaikzcacjamlw64g3xkk81m3pb4vz4an12cv8nb7kb20x9l";
};
buildInputs = [
coreutils
patchelf
@ -127,10 +128,4 @@ stdenv.mkDerivation rec {
# we did this in prefixup already
dontPatchELF = true;
meta = {
description = "Wolfram Mathematica computational software system";
homepage = "http://www.wolfram.com/mathematica/";
license = lib.licenses.unfree;
};
}

@ -1,14 +1,26 @@
{ lib, stdenv
, coreutils
{ lib
, patchelf
, requireFile
, callPackage
, stdenv
# arguments from default.nix
, lang
, meta
, name
, src
, version
# dependencies
, alsa-lib
, coreutils
, cudaPackages
, dbus
, fontconfig
, freetype
, gcc
, glib
, libGL
, libGLU
, libuuid
, libxml2
, ncurses
, opencv2
, openssl
@ -16,23 +28,12 @@
, xkeyboard_config
, xorg
, zlib
, libxml2
, libuuid
, lang ? "en"
, libGL
, libGLU
# options
, cudaSupport
}:
let
l10n =
import ./l10ns.nix {
lib = lib;
inherit requireFile lang;
majorVersion = "11";
};
in
stdenv.mkDerivation rec {
inherit (l10n) version name src;
inherit meta name src version;
buildInputs = [
coreutils
@ -141,10 +142,4 @@ stdenv.mkDerivation rec {
# we did this in prefixup already
dontPatchELF = true;
meta = {
description = "Wolfram Mathematica computational software system";
homepage = "http://www.wolfram.com/mathematica/";
license = lib.licenses.unfree;
};
}

@ -1,9 +1,17 @@
{ lib
, stdenv
, coreutils
, patchelf
, requireFile
, stdenv
# arguments from default.nix
, lang
, meta
, name
, src
, version
# dependencies
, alsa-lib
, coreutils
, cudaPackages
, fontconfig
, freetype
, gcc
@ -13,6 +21,8 @@
, openssl
, unixODBC
, xorg
# options
, cudaSupport
}:
let
@ -23,18 +33,8 @@ let
throw "Mathematica requires i686-linux or x86_64 linux";
in
stdenv.mkDerivation rec {
inherit meta src version;
pname = "mathematica";
version = "9.0.0";
src = requireFile {
name = "Mathematica_${version}_LINUX.sh";
message = ''
This nix expression requires that Mathematica_9.0.0_LINUX.sh is
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>.
'';
sha256 = "106zfaplhwcfdl9rdgs25x83xra9zcny94gb22wncbfxvrsk3a4q";
};
buildInputs = [
coreutils
@ -114,10 +114,4 @@ stdenv.mkDerivation rec {
# we did this in prefixup already
dontPatchELF = true;
meta = {
description = "Wolfram Mathematica computational software system";
homepage = "http://www.wolfram.com/mathematica/";
license = lib.licenses.unfree;
};
}

@ -1,173 +1,48 @@
{ lib
, stdenv
, autoPatchelfHook
, buildEnv
, makeWrapper
, requireFile
, alsa-lib
, cups
, dbus
, flite
, fontconfig
, freetype
, gcc-unwrapped
, glib
, gmpxx
, keyutils
, libGL
, libGLU
, libpcap
, libtins
, libuuid
, libxkbcommon
, libxml2
, llvmPackages_12
, matio
, mpfr
, ncurses
, opencv4
, openjdk11
, openssl
, pciutils
, tre
, unixODBC
, xkeyboard_config
, xorg
, zlib
{ callPackage
, config
, lib
, cudaPackages
, cudaSupport ? config.cudaSupport or false
, lang ? "en"
, version ? null
}:
let
l10n = import ./l10ns.nix {
inherit lib requireFile lang;
};
in stdenv.mkDerivation {
inherit (l10n) version name src;
nativeBuildInputs = [
autoPatchelfHook
makeWrapper
];
buildInputs = [
alsa-lib
cups.lib
dbus
flite
fontconfig
freetype
glib
gmpxx
keyutils.lib
libGL
libGLU
libpcap
libtins
libuuid
libxkbcommon
libxml2
llvmPackages_12.libllvm.lib
matio
mpfr
ncurses
opencv4
openjdk11
openssl
pciutils
tre
unixODBC
xkeyboard_config
] ++ (with xorg; [
libICE
libSM
libX11
libXScrnSaver
libXcomposite
libXcursor
libXdamage
libXext
libXfixes
libXi
libXinerama
libXmu
libXrandr
libXrender
libXtst
libxcb
]);
wrapProgramFlags = [
"--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ gcc-unwrapped.lib zlib ]}"
"--prefix PATH : ${lib.makeBinPath [ stdenv.cc ]}"
# Fix libQt errors - #96490
"--set USE_WOLFRAM_LD_LIBRARY_PATH 1"
# Fix xkeyboard config path for Qt
"--set QT_XKB_CONFIG_ROOT ${xkeyboard_config}/share/X11/xkb"
];
unpackPhase = ''
runHook preUnpack
# Find offset from file
offset=$(${stdenv.shell} -c "$(grep -axm1 -e 'offset=.*' $src); echo \$offset" $src)
tail -c +$(($offset + 1)) $src | tar -xf -
runHook postUnpack
'';
installPhase = ''
runHook preInstall
cd "$TMPDIR/Unix/Installer"
mkdir -p "$out/lib/udev/rules.d"
# Patch MathInstaller's shebangs and udev rules dir
patchShebangs MathInstaller
substituteInPlace MathInstaller \
--replace /etc/udev/rules.d $out/lib/udev/rules.d
# Remove PATH restriction, root and avahi daemon checks, and hostname call
sed -i '
s/^PATH=/# &/
s/isRoot="false"/# &/
s/^checkAvahiDaemon$/# &/
s/`hostname`/""/
' MathInstaller
# NOTE: some files placed under HOME may be useful
XDG_DATA_HOME="$out/share" HOME="$TMPDIR/home" vernierLink=y \
./MathInstaller -execdir="$out/bin" -targetdir="$out/libexec/Mathematica" -auto -verbose -createdir=y
# Check if MathInstaller produced any errors
errLog="$out/libexec/Mathematica/InstallErrors"
if [ -f "$errLog" ]; then
echo "Installation errors:"
cat "$errLog"
return 1
fi
runHook postInstall
'';
preFixup = ''
for bin in $out/libexec/Mathematica/Executables/*; do
wrapProgram "$bin" ''${wrapProgramFlags[@]}
done
'';
dontConfigure = true;
dontBuild = true;
# This is primarily an IO bound build; there's little benefit to building remotely
preferLocalBuild = true;
# All binaries are already stripped
dontStrip = true;
# NOTE: Some deps are still not found; ignore for now
autoPatchelfIgnoreMissingDeps = true;
let versions = callPackage ./versions.nix { };
matching-versions =
lib.sort (v1: v2: lib.versionAtLeast v1.version v2.version) (lib.filter
(v: v.lang == lang
&& (if version == null then true else isMatching v.version version))
versions);
found-version =
if matching-versions == []
then throw ("No registered Mathematica version found to match"
+ " version=${version} and language=${lang}")
else lib.head matching-versions;
specific-drv = ./. + "/(lib.versions.major found-version.version).nix";
real-drv = if lib.pathExists specific-drv
then specific-drv
else ./generic.nix;
isMatching = v1: v2:
let as = lib.splitVersion v1;
bs = lib.splitVersion v2;
n = lib.min (lib.length as) (lib.length bs);
sublist = l: lib.sublist 0 n l;
in lib.compareLists lib.compare (sublist as) (sublist bs) == 0;
in
callPackage real-drv {
inherit cudaSupport cudaPackages;
inherit (found-version) version lang src;
name = ("mathematica"
+ lib.optionalString cudaSupport "-cuda"
+ "-${found-version.version}"
+ lib.optionalString (lang != "en") "-${lang}");
meta = with lib; {
description = "Wolfram Mathematica computational software system";
homepage = "http://www.wolfram.com/mathematica/";

@ -0,0 +1,192 @@
{ addOpenGLRunpath
, autoPatchelfHook
, lib
, makeWrapper
, requireFile
, runCommand
, stdenv
, symlinkJoin
# arguments from default.nix
, lang
, meta
, name
, src
, version
# dependencies
, alsa-lib
, cudaPackages
, cups
, dbus
, flite
, fontconfig
, freetype
, gcc-unwrapped
, glib
, gmpxx
, keyutils
, libGL
, libGLU
, libpcap
, libtins
, libuuid
, libxkbcommon
, libxml2
, llvmPackages_12
, matio
, mpfr
, ncurses
, opencv4
, openjdk11
, openssl
, pciutils
, tre
, unixODBC
, xkeyboard_config
, xorg
, zlib
# options
, cudaSupport
}:
let cudaEnv = symlinkJoin {
name = "mathematica-cuda-env";
paths = with cudaPackages; [
cuda_cudart cuda_nvcc libcublas libcufft libcurand libcusparse
];
postBuild = ''
ln -s ${addOpenGLRunpath.driverLink}/lib/libcuda.so $out/lib
ln -s lib $out/lib64
'';
};
in stdenv.mkDerivation {
inherit meta name src version;
nativeBuildInputs = [
autoPatchelfHook
makeWrapper
] ++ lib.optional cudaSupport addOpenGLRunpath;
buildInputs = [
alsa-lib
cups.lib
dbus
flite
fontconfig
freetype
glib
gmpxx
keyutils.lib
libGL
libGLU
libpcap
libtins
libuuid
libxkbcommon
libxml2
llvmPackages_12.libllvm.lib
matio
mpfr
ncurses
opencv4
openjdk11
openssl
pciutils
tre
unixODBC
xkeyboard_config
] ++ (with xorg; [
libICE
libSM
libX11
libXScrnSaver
libXcomposite
libXcursor
libXdamage
libXext
libXfixes
libXi
libXinerama
libXmu
libXrandr
libXrender
libXtst
libxcb
]) ++ lib.optional cudaSupport cudaEnv;
wrapProgramFlags = [
"--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ gcc-unwrapped.lib zlib ]}"
"--prefix PATH : ${lib.makeBinPath [ stdenv.cc ]}"
# Fix libQt errors - #96490
"--set USE_WOLFRAM_LD_LIBRARY_PATH 1"
# Fix xkeyboard config path for Qt
"--set QT_XKB_CONFIG_ROOT ${xkeyboard_config}/share/X11/xkb"
] ++ lib.optionals cudaSupport [
"--set CUDA_PATH ${cudaEnv}"
"--set NVIDIA_DRIVER_LIBRARY_PATH ${addOpenGLRunpath.driverLink}/lib/libnvidia-tls.so"
"--set CUDA_LIBRARY_PATH ${addOpenGLRunpath.driverLink}/lib/libcuda.so"
];
unpackPhase = ''
runHook preUnpack
# Find offset from file
offset=$(${stdenv.shell} -c "$(grep -axm1 -e 'offset=.*' $src); echo \$offset" $src)
tail -c +$(($offset + 1)) $src | tar -xf -
runHook postUnpack
'';
installPhase = ''
runHook preInstall
cd "$TMPDIR/Unix/Installer"
mkdir -p "$out/lib/udev/rules.d"
# Patch MathInstaller's shebangs and udev rules dir
patchShebangs MathInstaller
substituteInPlace MathInstaller \
--replace /etc/udev/rules.d $out/lib/udev/rules.d
# Remove PATH restriction, root and avahi daemon checks, and hostname call
sed -i '
s/^PATH=/# &/
s/isRoot="false"/# &/
s/^checkAvahiDaemon$/# &/
s/`hostname`/""/
' MathInstaller
# NOTE: some files placed under HOME may be useful
XDG_DATA_HOME="$out/share" HOME="$TMPDIR/home" vernierLink=y \
./MathInstaller -execdir="$out/bin" -targetdir="$out/libexec/Mathematica" -auto -verbose -createdir=y
# Check if MathInstaller produced any errors
errLog="$out/libexec/Mathematica/InstallErrors"
if [ -f "$errLog" ]; then
echo "Installation errors:"
cat "$errLog"
return 1
fi
runHook postInstall
'';
preFixup = ''
for bin in $out/libexec/Mathematica/Executables/*; do
wrapProgram "$bin" ''${wrapProgramFlags[@]}
done
'';
dontConfigure = true;
dontBuild = true;
# This is primarily an IO bound build; there's little benefit to building remotely
preferLocalBuild = true;
# All binaries are already stripped
dontStrip = true;
# NOTE: Some deps are still not found; ignore for now
autoPatchelfIgnoreMissingDeps = true;
}

@ -1,106 +0,0 @@
{ lib
, requireFile
, lang
, majorVersion ? null
}:
let allVersions = with lib; flip map
# N.B. Versions in this list should be ordered from newest to oldest.
[
{
version = "13.0.1";
lang = "en";
language = "English";
sha256 = "3672a920c1b4af1afd480733f6d67665baf8258757dfe59a6ed6d7440cf26dba";
installer = "Mathematica_13.0.1_BNDL_LINUX.sh";
}
{
version = "13.0.0";
lang = "en";
language = "English";
sha256 = "15bbad39a5995031325d1d178f63b00e71706d3ec9001eba6d1681fbc991d3e1";
installer = "Mathematica_13.0.0_BNDL_LINUX.sh";
}
{
version = "12.3.1";
lang = "en";
language = "English";
sha256 = "51b9cab12fd91b009ea7ad4968a2c8a59e94dc55d2e6cc1d712acd5ba2c4d509";
installer = "Mathematica_12.3.1_LINUX.sh";
}
{
version = "12.3.0";
lang = "en";
language = "English";
sha256 = "045df045f6e796ded59f64eb2e0f1949ac88dcba1d5b6e05fb53ea0a4aed7215";
installer = "Mathematica_12.3.0_LINUX.sh";
}
{
version = "12.2.0";
lang = "en";
language = "English";
sha256 = "3b6676a203c6adb7e9c418a5484b037974287b5be09c64e7dfea74ddc0e400d7";
installer = "Mathematica_12.2.0_LINUX.sh";
}
{
version = "12.1.1";
lang = "en";
language = "English";
sha256 = "02mk8gmv8idnakva1nc7r7mx8ld02lk7jgsj1zbn962aps3bhixd";
installer = "Mathematica_12.1.1_LINUX.sh";
}
{
version = "12.1.0";
lang = "en";
language = "English";
sha256 = "15m9l20jvkxh5w6mbp81ys7mx2lx5j8acw5gz0il89lklclgb8z7";
installer = "Mathematica_12.1.0_LINUX.sh";
}
{
version = "12.0.0";
lang = "en";
language = "English";
sha256 = "b9fb71e1afcc1d72c200196ffa434512d208fa2920e207878433f504e58ae9d7";
installer = "Mathematica_12.0.0_LINUX.sh";
}
{
version = "11.3.0";
lang = "en";
language = "English";
sha256 = "0fcfe208c1eac8448e7be3af0bdb84370b17bd9c5d066c013928c8ee95aed10e";
installer = "Mathematica_11.3.0_LINUX.sh";
}
{
version = "11.2.0";
lang = "ja";
language = "Japanese";
sha256 = "916392edd32bed8622238df435dd8e86426bb043038a3336f30df10d819b49b1";
installer = "Mathematica_11.2.0_ja_LINUX.sh";
}
]
({ version, lang, language, sha256, installer }: {
inherit version lang;
name = "mathematica-${version}" + optionalString (lang != "en") "-${lang}";
src = requireFile {
name = installer;
message = ''
This nix expression requires that ${installer} is
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>.
'';
inherit sha256;
};
});
minVersion =
with lib;
if majorVersion == null
then elemAt (builtins.splitVersion (elemAt allVersions 0).version) 0
else majorVersion;
maxVersion = toString (1 + builtins.fromJSON minVersion);
in
with lib;
findFirst (l: (l.lang == lang
&& l.version >= minVersion
&& l.version < maxVersion))
(throw "Version ${minVersion} in language ${lang} not supported")
allVersions

@ -0,0 +1,103 @@
{ lib, requireFile }:
let versions = [
{
version = "13.0.1";
lang = "en";
language = "English";
sha256 = "sha256-NnKpIMG0rxr9SAcz9tZ2Zbr4JYdX3+WabtbXRAzybbo=";
installer = "Mathematica_13.0.1_BNDL_LINUX.sh";
}
{
version = "13.0.0";
lang = "en";
language = "English";
sha256 = "sha256-FbutOaWZUDEyXR0Xj2OwDnFwbT7JAB66bRaB+8mR0+E=";
installer = "Mathematica_13.0.0_BNDL_LINUX.sh";
}
{
version = "12.3.1";
lang = "en";
language = "English";
sha256 = "sha256-UbnKsS/ZGwCep61JaKLIpZ6U3FXS5swdcSrNW6LE1Qk=";
installer = "Mathematica_12.3.1_LINUX.sh";
}
{
version = "12.3.0";
lang = "en";
language = "English";
sha256 = "sha256-BF3wRfbnlt7Vn2TrLg8ZSayI3LodW24F+1PqCkrtchU=";
installer = "Mathematica_12.3.0_LINUX.sh";
}
{
version = "12.2.0";
lang = "en";
language = "English";
sha256 = "sha256-O2Z2ogPGrbfpxBilSEsDeXQoe1vgnGTn3+p03cDkANc=";
installer = "Mathematica_12.2.0_LINUX.sh";
}
{
version = "12.1.1";
lang = "en";
language = "English";
sha256 = "sha256-rUe4hr5KmGTXD1I/eSYVoFHU68mH2aD2VLZFtOtDswo=";
installer = "Mathematica_12.1.1_LINUX.sh";
}
{
version = "12.1.0";
lang = "en";
language = "English";
sha256 = "sha256-56P1KKOTJkQj+K9wppAsnYpej/YB3VUNL7DPLYGgqZY=";
installer = "Mathematica_12.1.0_LINUX.sh";
}
{
version = "12.0.0";
lang = "en";
language = "English";
sha256 = "sha256-uftx4a/MHXLCABlv+kNFEtII+ikg4geHhDP1BOWK6dc=";
installer = "Mathematica_12.0.0_LINUX.sh";
}
{
version = "11.3.0";
lang = "en";
language = "English";
sha256 = "sha256-D8/iCMHqyESOe+OvC9uENwsXvZxdBmwBOSjI7pWu0Q4=";
installer = "Mathematica_11.3.0_LINUX.sh";
}
{
version = "11.2.0";
lang = "ja";
language = "Japanese";
sha256 = "sha256-kWOS7dMr7YYiI430Nd2OhkJrsEMDijM28w3xDYGbSbE=";
installer = "Mathematica_11.2.0_ja_LINUX.sh";
}
{
version = "9.0.0";
lang = "en";
language = "English";
sha256 = "sha256-mKgxdd7dLWa5EOuR5C37SeU+UC9Cv5YTbY5xSK9y34A=";
installer = "Mathematica_9.0.0_LINUX.sh";
}
{
version = "10.0.2";
lang = "en";
language = "English";
sha256 = "sha256-NHUg1jzLos1EsIr8TdYdNaA5+3jEcFqVZIr9GVVUXrQ=";
installer = "Mathematica_10.0.2_LINUX.sh";
}
];
in
lib.flip map versions ({ version, lang, language, sha256, installer }: {
inherit version lang;
src = requireFile {
name = installer;
message = ''
This nix expression requires that ${installer} is
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>.
'';
inherit sha256;
};
})

@ -33001,9 +33001,22 @@ with pkgs;
clmagma = callPackage ../development/libraries/science/math/clmagma { };
mathematica = callPackage ../applications/science/math/mathematica { };
mathematica9 = callPackage ../applications/science/math/mathematica/9.nix { };
mathematica10 = callPackage ../applications/science/math/mathematica/10.nix { };
mathematica11 = callPackage ../applications/science/math/mathematica/11.nix { };
mathematica-cuda = callPackage ../applications/science/math/mathematica {
cudaSupport = true;
};
mathematica9 = callPackage ../applications/science/math/mathematica {
version = "9";
};
mathematica10 = callPackage ../applications/science/math/mathematica {
version = "10";
};
mathematica11 = callPackage ../applications/science/math/mathematica {
version = "11";
};
metis = callPackage ../development/libraries/science/math/metis {};

Loading…
Cancel
Save