mathematica: enable installation of localized editions

For now English (default) and Japanese editions only.
Fill out information in `l10ns.nix` to add the other localized editions.
Example usage: `mathematica.override { lang = "ja"; }` derives Japanese edition.

+42 -14
+9 -14
pkgs/applications/science/math/mathematica/default.nix
··· 1 1 { stdenv 2 2 , coreutils 3 3 , patchelf 4 - , requireFile 4 + , callPackage 5 5 , alsaLib 6 6 , dbus 7 7 , fontconfig ··· 18 18 , zlib 19 19 , libxml2 20 20 , libuuid 21 + , lang ? "en" 21 22 }: 22 23 23 24 let ··· 26 27 "Linux" 27 28 else 28 29 throw "Mathematica requires i686-linux or x86_64 linux"; 30 + 31 + l10n = 32 + with stdenv.lib; 33 + with callPackage ./l10ns.nix {}; 34 + flip (findFirst (l: l.lang == lang)) l10ns 35 + (throw "Language '${lang}' not supported"); 29 36 in 30 37 stdenv.mkDerivation rec { 31 - version = "11.2.0"; 32 - 33 - name = "mathematica-${version}"; 34 - 35 - src = requireFile rec { 36 - name = "Mathematica_${version}_LINUX.sh"; 37 - message = '' 38 - This nix expression requires that ${name} is 39 - already part of the store. Find the file on your Mathematica CD 40 - and add it to the nix store with nix-store --add-fixed sha256 <FILE>. 41 - ''; 42 - sha256 = "4a1293cc1c404303aa1cab1bd273c7be151d37ac5ed928fbbb18e9c5ab2d8df9"; 43 - }; 38 + inherit (l10n) version name src; 44 39 45 40 buildInputs = [ 46 41 coreutils
+33
pkgs/applications/science/math/mathematica/l10ns.nix
··· 1 + { lib, requireFile }: 2 + 3 + with lib; 4 + { 5 + l10ns = flip map 6 + [ 7 + { 8 + version = "11.2.0"; 9 + lang = "en"; 10 + language = "English"; 11 + sha256 = "4a1293cc1c404303aa1cab1bd273c7be151d37ac5ed928fbbb18e9c5ab2d8df9"; 12 + } 13 + { 14 + version = "11.2.0"; 15 + lang = "ja"; 16 + language = "Japanese"; 17 + sha256 = "916392edd32bed8622238df435dd8e86426bb043038a3336f30df10d819b49b1"; 18 + } 19 + ] 20 + ({ version, lang, language, sha256 }: { 21 + inherit version lang; 22 + name = "mathematica-${version}" + optionalString (lang != "en") "-${lang}"; 23 + src = requireFile rec { 24 + name = "Mathematica_${version}" + optionalString (lang != "en") "_${language}" + "_LINUX.sh"; 25 + message = '' 26 + This nix expression requires that ${name} is 27 + already part of the store. Find the file on your Mathematica CD 28 + and add it to the nix store with nix-store --add-fixed sha256 <FILE>. 29 + ''; 30 + inherit sha256; 31 + }; 32 + }); 33 + }