at v192 136 lines 3.3 kB view raw
1{ stdenv 2, coreutils 3, patchelf 4, requireFile 5, alsaLib 6, fontconfig 7, freetype 8, gcc 9, glib 10, libpng 11, ncurses 12, opencv 13, openssl 14, unixODBC 15, xlibs 16, zlib 17, libxml2 18, libuuid 19}: 20 21let 22 platform = 23 if stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux" then 24 "Linux" 25 else 26 throw "Mathematica requires i686-linux or x86_64 linux"; 27in 28stdenv.mkDerivation rec { 29 version = "10.0.2"; 30 31 name = "mathematica-${version}"; 32 33 src = requireFile rec { 34 name = "Mathematica_${version}_LINUX.sh"; 35 message = '' 36 This nix expression requires that ${name} is 37 already part of the store. Find the file on your Mathematica CD 38 and add it to the nix store with nix-store --add-fixed sha256 <FILE>. 39 ''; 40 sha256 = "1d2yaiaikzcacjamlw64g3xkk81m3pb4vz4an12cv8nb7kb20x9l"; 41 }; 42 43 buildInputs = [ 44 coreutils 45 patchelf 46 alsaLib 47 coreutils 48 fontconfig 49 freetype 50 gcc.cc 51 gcc.libc 52 glib 53 ncurses 54 opencv 55 openssl 56 unixODBC 57 libxml2 58 libuuid 59 ] ++ (with xlibs; [ 60 libX11 61 libXext 62 libXtst 63 libXi 64 libXmu 65 libXrender 66 libxcb 67 libXcursor 68 libXfixes 69 libXrandr 70 libICE 71 libSM 72 ]); 73 74 ldpath = stdenv.lib.makeLibraryPath buildInputs 75 + stdenv.lib.optionalString (stdenv.system == "x86_64-linux") 76 (":" + stdenv.lib.makeSearchPath "lib64" buildInputs); 77 78 phases = "unpackPhase installPhase fixupPhase"; 79 80 unpackPhase = '' 81 echo "=== Extracting makeself archive ===" 82 # find offset from file 83 offset=$(${stdenv.shell} -c "$(grep -axm1 -e 'offset=.*' $src); echo \$offset" $src) 84 dd if="$src" ibs=$offset skip=1 | tar -xf - 85 cd Unix 86 ''; 87 88 installPhase = '' 89 cd Installer 90 # don't restrict PATH, that has already been done 91 sed -i -e 's/^PATH=/# PATH=/' MathInstaller 92 93 echo "=== Running MathInstaller ===" 94 ./MathInstaller -auto -createdir=y -execdir=$out/bin -targetdir=$out/libexec/Mathematica -platforms=${platform} -silent 95 ''; 96 97 preFixup = '' 98 echo "=== PatchElfing away ===" 99 find $out/libexec/Mathematica/SystemFiles -type f -perm -0100 | while read f; do 100 type=$(readelf -h "$f" 2>/dev/null | grep 'Type:' | sed -e 's/ *Type: *\([A-Z]*\) (.*/\1/') 101 if [ -z "$type" ]; then 102 : 103 elif [ "$type" == "EXEC" ]; then 104 echo "patching $f executable <<" 105 patchelf --shrink-rpath "$f" 106 patchelf \ 107 --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ 108 --set-rpath "$(patchelf --print-rpath "$f"):${ldpath}" \ 109 "$f" \ 110 && patchelf --shrink-rpath "$f" \ 111 || echo unable to patch ... ignoring 1>&2 112 elif [ "$type" == "DYN" ]; then 113 echo "patching $f library <<" 114 patchelf \ 115 --set-rpath "$(patchelf --print-rpath "$f"):${ldpath}" \ 116 "$f" \ 117 && patchelf --shrink-rpath "$f" \ 118 || echo unable to patch ... ignoring 1>&2 119 else 120 echo "not patching $f <<: unknown elf type" 121 fi 122 done 123 ''; 124 125 # all binaries are already stripped 126 dontStrip = true; 127 128 # we did this in prefixup already 129 dontPatchELF = true; 130 131 meta = { 132 description = "Wolfram Mathematica computational software system"; 133 homepage = "http://www.wolfram.com/mathematica/"; 134 license = stdenv.lib.licenses.unfree; 135 }; 136}