1{
2 callPackage,
3 config,
4 lib,
5 cudaPackages,
6 cudaSupport ? config.cudaSupport,
7 lang ? "en",
8 webdoc ? false,
9 version ? null,
10 /*
11 If you wish to completely override the src, use:
12 my_mathematica = mathematica.override {
13 source = pkgs.requireFile {
14 name = "Mathematica_XX.X.X_BNDL_LINUX.sh";
15 # Get this hash via a command similar to this:
16 # nix-store --query --hash \
17 # $(nix store add-path Mathematica_XX.X.X_BNDL_LINUX.sh --name 'Mathematica_XX.X.X_BNDL_LINUX.sh')
18 sha256 = "0000000000000000000000000000000000000000000000000000";
19 message = ''
20 Your override for Mathematica includes a different src for the installer,
21 and it is missing.
22 '';
23 hashMode = "recursive";
24 };
25 }
26 */
27 source ? null,
28}:
29
30let
31 versions = callPackage ./versions.nix { };
32
33 matching-versions = lib.sort (v1: v2: lib.versionOlder v2.version v1.version) (
34 lib.filter (
35 v: v.lang == lang && (version == null || isMatching v.version version) && matchesDoc v
36 ) versions
37 );
38
39 found-version =
40 if matching-versions == [ ] then
41 throw (
42 "No registered Mathematica version found to match"
43 + " version=${toString version} and language=${lang},"
44 + " ${if webdoc then "using web documentation" else "and with local documentation"}"
45 )
46 else
47 lib.head matching-versions;
48
49 isMatching =
50 v1: v2:
51 let
52 as = lib.splitVersion v1;
53 bs = lib.splitVersion v2;
54 n = lib.min (lib.length as) (lib.length bs);
55 sublist = l: lib.sublist 0 n l;
56 in
57 lib.compareLists lib.compare (sublist as) (sublist bs) == 0;
58
59 matchesDoc = v: (builtins.match ".*[0-9]_LIN(UX)?.sh" v.src.name != null) == webdoc;
60
61in
62
63callPackage ./generic.nix {
64 inherit cudaSupport cudaPackages;
65 inherit (found-version) version lang;
66 src = if source == null then found-version.src else source;
67 name = (
68 "mathematica"
69 + lib.optionalString cudaSupport "-cuda"
70 + "-${found-version.version}"
71 + lib.optionalString (lang != "en") "-${lang}"
72 );
73 meta = with lib; {
74 description = "Wolfram Mathematica computational software system";
75 homepage = "https://www.wolfram.com/mathematica/";
76 license = licenses.unfree;
77 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
78 maintainers = with maintainers; [
79 herberteuler
80 rafaelrc
81 ];
82 platforms = [ "x86_64-linux" ];
83 };
84}