biglybt: 3.5.0.0 -> 3.6.0.0
[NixPkgs.git] / pkgs / applications / science / math / wolfram-engine / default.nix
blob685bc1bff3b18e72bdb023ce3f9a6df5cc89815e
1 { lib
2 , stdenv
3 , autoPatchelfHook
4 , requireFile
5 , callPackage
6 , makeWrapper
7 , alsa-lib
8 , dbus
9 , fontconfig
10 , freetype
11 , gcc
12 , glib
13 , installShellFiles
14 , libssh2
15 , ncurses
16 , opencv4
17 , openssl
18 , unixODBC
19 , xkeyboard_config
20 , xorg
21 , zlib
22 , libxml2
23 , libuuid
24 , lang ? "en"
25 , libGL
26 , libGLU
27 , wrapQtAppsHook
30 let
31   l10n = import ./l10ns.nix {
32     lib = lib;
33     inherit requireFile lang;
34   };
35   dirName = "WolframEngine";
37 stdenv.mkDerivation rec {
38   inherit (l10n) version name src;
40   nativeBuildInputs = [
41     autoPatchelfHook
42     installShellFiles
43     wrapQtAppsHook
44   ];
45   dontWrapQtApps = true;
47   buildInputs = [
48     alsa-lib
49     dbus
50     fontconfig
51     freetype
52     gcc.cc
53     gcc.libc
54     glib
55     libssh2
56     ncurses
57     opencv4
58     openssl
59     stdenv.cc.cc.lib
60     unixODBC
61     xkeyboard_config
62     libxml2
63     libuuid
64     zlib
65     libGL
66     libGLU
67   ] ++ (with xorg; [
68     libX11
69     libXext
70     libXtst
71     libXi
72     libXmu
73     libXrender
74     libxcb
75     libXcursor
76     libXfixes
77     libXrandr
78     libICE
79     libSM
80   ]);
82   # some bundled libs are found through LD_LIBRARY_PATH
83   autoPatchelfIgnoreMissingDeps = true;
85   ldpath = lib.makeLibraryPath buildInputs
86     + lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux")
87       (":" + lib.makeSearchPathOutput "lib" "lib64" buildInputs);
89   unpackPhase = ''
90     # find offset from file
91     offset=$(${stdenv.shell} -c "$(grep -axm1 -e 'offset=.*' $src); echo \$offset" $src)
92     dd if="$src" ibs=$offset skip=1 | tar -xf -
93     cd Unix
94   '';
96   installPhase = ''
97     cd Installer
98     sed -i -e 's/^PATH=/# PATH=/' -e 's/=`id -[ug]`/=0/' MathInstaller
100     # Installer wants to write default config in HOME
101     export HOME=$(mktemp -d)
103     # Fix the installation script
104     patchShebangs MathInstaller
105     substituteInPlace MathInstaller \
106       --replace '`hostname`' "" \
107       --replace "chgrp" "# chgrp" \
108       --replace "chown" ": # chown"
110     # Install the desktop items
111     export XDG_DATA_HOME="$out/share"
113     ./MathInstaller -auto -createdir=y -execdir=$out/bin -targetdir=$out/libexec/${dirName} -silent
115     # Fix library paths
116     cd $out/libexec/${dirName}/Executables
117     for path in MathKernel math mcc wolfram; do
118       makeWrapper $out/libexec/${dirName}/Executables/$path $out/bin/$path --set LD_LIBRARY_PATH "${zlib}/lib:${stdenv.cc.cc.lib}/lib:${libssh2}/lib:\''${LD_LIBRARY_PATH}"
119     done
121     for path in WolframKernel wolframscript; do
122       makeWrapper $out/libexec/${dirName}/SystemFiles/Kernel/Binaries/Linux-x86-64/$path $out/bin/$path --set LD_LIBRARY_PATH "${zlib}/lib:${stdenv.cc.cc.lib}/lib:${libssh2}/lib:\''${LD_LIBRARY_PATH}"
123     done
125     wrapQtApp "$out/libexec/${dirName}/SystemFiles/FrontEnd/Binaries/Linux-x86-64/WolframPlayer" \
126       --set LD_LIBRARY_PATH "${zlib}/lib:${stdenv.cc.cc.lib}/lib:${libssh2}/lib:\''${LD_LIBRARY_PATH}" \
127       --set QT_XKB_CONFIG_ROOT "${xkeyboard_config}/share/X11/xkb"
128     if ! isELF "$out/libexec/${dirName}/SystemFiles/FrontEnd/Binaries/Linux-x86-64/WolframPlayer"; then
129       substituteInPlace $out/libexec/${dirName}/SystemFiles/FrontEnd/Binaries/Linux-x86-64/WolframPlayer \
130         --replace "TopDirectory=" "TopDirectory=$out/libexec/${dirName} #";
131     fi
133     for path in WolframPlayer wolframplayer; do
134       makeWrapper $out/libexec/${dirName}/Executables/$path $out/bin/$path
135     done
137     # Install man pages
138     installManPage $out/libexec/${dirName}/SystemFiles/SystemDocumentation/Unix/*
139   '';
141   # This is primarily an IO bound build; there's little benefit to building remotely.
142   preferLocalBuild = true;
144   # Stripping causes the program to core dump.
145   dontStrip = true;
147   meta = with lib; {
148     description = "Wolfram Engine computational software system";
149     homepage = "https://www.wolfram.com/engine/";
150     sourceProvenance = with sourceTypes; [ binaryNativeCode ];
151     license = licenses.unfree;
152     maintainers = with maintainers; [ fbeffa ];
153     platforms = [ "x86_64-linux" ];
154   };