@ -1,167 +1,172 @@
{ lib , stdenv
, coreutils
, patchelf
, requireFile
, callPackage
{ lib
, stdenv
, autoPatchelfHook
, buildEnv
, makeWrapper
, requireFile
, alsa-lib
, cups
, dbus
, flite
, fontconfig
, freetype
, gcc
, gcc-unwrapped
, glib
, libssh2
, gmpxx
, keyutils
, libGL
, libGLU
, libpcap
, libtins
, libuuid
, libxkbcommon
, libxml2
, llvmPackages_12
, matio
, mpfr
, ncurses
, opencv4
, openjdk11
, openssl
, pciutils
, tre
, unixODBC
, xkeyboard_config
, xorg
, zlib
, libxml2
, libuuid
, lang ? " e n "
, libGL
, libGLU
} :
let
l10n =
import ./l10ns.nix {
lib = lib ;
inherit requireFile lang ;
} ;
in
stdenv . mkDerivation rec {
l10n = import ./l10ns.nix {
inherit lib requireFile lang ;
} ;
in stdenv . mkDerivation {
inherit ( l10n ) version name src ;
buildInputs = [
coreutils
patchelf
nativeBuildInputs = [
autoPatchelfHook
makeWrapper
] ;
buildInputs = [
alsa-lib
coreutils
cups . lib
dbus
flite
fontconfig
freetype
gcc . cc
gcc . libc
glib
libssh2
gmpxx
keyutils . lib
libGL
libGLU
libpcap
libtins
libuuid
libxkbcommon
libxml2
llvmPackages_12 . libllvm . lib
matio
mpfr
ncurses
opencv4
openjdk11
openssl
stdenv . cc . cc . lib
pciutils
tre
unixODBC
xkeyboard_config
libxml2
libuuid
zlib
libGL
libGLU
] ++ ( with xorg ; [
libICE
libSM
libX11
libXScrnSaver
libXcomposite
libXcursor
libXdamage
libXext
libXtst
libXfixes
libXi
libXinerama
libXmu
libXrandr
libXrender
libXtst
libxcb
libXcursor
libXfixes
libXrandr
libICE
libSM
] ) ;
ldpath = lib . makeLibraryPath buildInputs
+ lib . optionalString ( stdenv . hostPlatform . system == " x 8 6 _ 6 4 - l i n u x " )
( " : " + lib . makeSearchPathOutput " l i b " " l i b 6 4 " buildInputs ) ;
wrapProgramFlags = [
" - - p r e f i x L D _ L I B R A R Y _ P A T H : ${ lib . makeLibraryPath [ gcc-unwrapped . lib zlib ] } "
" - - p r e f i x P A T H : ${ lib . makeBinPath [ stdenv . cc ] } "
# Fix libQt errors - #96490
" - - s e t U S E _ W O L F R A M _ L D _ L I B R A R Y _ P A T H 1 "
# Fix xkeyboard config path for Qt
" - - s e t Q T _ X K B _ C O N F I G _ R O O T ${ xkeyboard_config } / s h a r e / X 1 1 / x k b "
] ;
unpackPhase = ''
echo " = = = E x t r a c t i n g m a k e s e l f a r c h i v e = = = "
# find offset from file
runHook preUnpack
# Find offset from file
offset = $ ( $ { stdenv . shell } - c " $ ( g r e p - a x m 1 - e ' o f f s e t = . * ' $ s r c ) ; e c h o \$ o f f s e t " $ src )
dd if = " $ s r c " ibs = $ offset skip = 1 | tar - xf -
cd Unix
tail - c + $ ( ( $ offset + 1 ) ) $ src | tar - xf -
runHook postUnpack
'' ;
installPhase = ''
cd Installer
# don't restrict PATH, that has already been done
sed - i - e ' s / ^ PATH = / # PATH=/' MathInstaller
# Fix the installation script as follows:
# 1. Adjust the shebang
# 2. Use the wrapper in the desktop items
substituteInPlace MathInstaller \
- - replace " / b i n / b a s h " " / b i n / s h " \
- - replace " E x e c u t a b l e s / M a t h e m a t i c a " " . . / . . / b i n / m a t h e m a t i c a "
# Install the desktop items
export XDG_DATA_HOME = " $ o u t / s h a r e "
runHook preInstall
echo " = = = R u n n i n g M a t h I n s t a l l e r = = = "
./MathInstaller - auto - createdir = y - execdir = $ out/bin - targetdir = $ out/libexec/Mathematica - silent
cd " $ T M P D I R / U n i x / I n s t a l l e r "
# Fix library paths
cd $ out/libexec/Mathematica/Executables
for path in mathematica MathKernel Mathematica WolframKernel wolfram math ; do
sed - i - e " 2 i e x p o r t L D _ L I B R A R Y _ P A T H = ${ zlib } / l i b : ${ stdenv . cc . cc . lib } / l i b : ${ libssh2 } / l i b : \' ' ${ LD_LIBRARY_PATH } \n " $ path
done
mkdir - p " $ o u t / l i b / u d e v / r u l e s . d "
# Fix xkeyboard config path for Qt
for path in mathematica Mathematica ; do
sed - i - e " 2 i e x p o r t Q T _ X K B _ C O N F I G _ R O O T = \" ${ xkeyboard_config } / s h a r e / X 1 1 / x k b \" \n " $ path
done
# Remove some broken libraries
rm - f $ out/libexec/Mathematica/SystemFiles/Libraries/Linux-x86-64/libz.so *
# Set environment variable to fix libQt errors - see https://github.com/NixOS/nixpkgs/issues/96490
wrapProgram $ out/bin/mathematica - - set USE_WOLFRAM_LD_LIBRARY_PATH 1
# 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 = " f a l s e " / # &/
s / ^ checkAvahiDaemon $ / # &/
s / ` hostname ` / " " /
' MathInstaller
# NOTE: some files placed under HOME may be useful
XDG_DATA_HOME = " $ o u t / s h a r e " HOME = " $ T M P D I R / h o m e " vernierLink = y \
./MathInstaller - execdir = " $ o u t / b i n " - targetdir = " $ o u t / l i b e x e c / M a t h e m a t i c a " - auto - verbose - createdir = y
# Check if MathInstaller produced any errors
errLog = " $ o u t / l i b e x e c / M a t h e m a t i c a / I n s t a l l E r r o r s "
if [ - f " $ e r r L o g " ] ; then
echo " I n s t a l l a t i o n e r r o r s : "
cat " $ e r r L o g "
return 1
fi
runHook postInstall
'' ;
preFixup = ''
echo " = = = P a t c h E l f i n g a w a y = = = "
# This code should be a bit forgiving of errors, unfortunately
set + e
find $ out/libexec/Mathematica/SystemFiles - type f - perm -0100 | while read f ; do
type = $ ( readelf - h " $ f " 2 > /dev/null | grep ' Type:' | sed - e ' s / * Type : * \ ( [ A-Z ] * \ ) ( . * / \ 1 / ' )
if [ - z " $ t y p e " ] ; then
:
elif [ " $ t y p e " == " E X E C " ] ; then
echo " p a t c h i n g $ f e x e c u t a b l e < < "
patchelf - - shrink-rpath " $ f "
patchelf \
- - set-interpreter " $ ( c a t $ N I X _ C C / n i x - s u p p o r t / d y n a m i c - l i n k e r ) " \
- - set-rpath " $ ( p a t c h e l f - - p r i n t - r p a t h " $ f " ) : ${ ldpath } " \
" $ f " \
&& patchelf - - shrink-rpath " $ f " \
|| echo unable to patch . . . ignoring 1 > & 2
elif [ " $ t y p e " == " D Y N " ] ; then
echo " p a t c h i n g $ f l i b r a r y < < "
patchelf \
- - set-rpath " $ ( p a t c h e l f - - p r i n t - r p a t h " $ f " ) : ${ ldpath } " \
" $ f " \
&& patchelf - - shrink-rpath " $ f " \
|| echo unable to patch . . . ignoring 1 > & 2
else
echo " n o t p a t c h i n g $ f < < : u n k n o w n e l f t y p e "
fi
for bin in $ out/libexec/Mathematica/Executables /* ; d o
wrapProgram " $ b i n " '' ${ wrapProgramFlags [ @ ] }
done
'' ;
dontConfigure = true ;
dontBuild = true ;
# This is primarily an IO bound build; there's little benefit to building remotely.
# This is primarily an IO bound build; there's little benefit to building remotely
preferLocalBuild = true ;
# a ll binaries are already stripped
# All binaries are already stripped
dontStrip = true ;
# we did this in prefixup already
dontPatchELF = true ;
# NOTE: Some deps are still not found; ignore for now
autoPatchelfIgnoreMissingDeps = true ;
meta = with lib ; {
description = " W o l f r a m M a t h e m a t i c a c o m p u t a t i o n a l s o f t w a r e s y s t e m " ;