at 22.05-pre 119 lines 5.4 kB view raw
1############################################################################ 2# This file mainly provides the `mathcomp` derivation, which is # 3# essentially a meta-package containing all core mathcomp libraries # 4# (ssreflect fingroup algebra solvable field character). They can be # 5# accessed individually through the passthrough attributes of mathcomp # 6# bearing the same names (mathcomp.ssreflect, etc). # 7############################################################################ 8# Compiling a custom version of mathcomp using `mathcomp.override`. # 9# This is the replacement for the former `mathcomp_ config` function. # 10# See the documentation at doc/languages-frameworks/coq.section.md. # 11############################################################################ 12 13{ lib, ncurses, which, graphviz, lua, fetchzip, 14 mkCoqDerivation, recurseIntoAttrs, withDoc ? false, single ? false, 15 coqPackages, coq, ocamlPackages, version ? null }@args: 16with builtins // lib; 17let 18 repo = "math-comp"; 19 owner = "math-comp"; 20 withDoc = single && (args.withDoc or false); 21 defaultVersion = with versions; switch coq.coq-version [ 22 { case = isGe "8.14"; out = "1.13.0"; } 23 { case = range "8.10" "8.13"; out = "1.12.0"; } 24 { case = range "8.7" "8.12"; out = "1.11.0"; } 25 { case = range "8.7" "8.11"; out = "1.10.0"; } 26 { case = range "8.7" "8.11"; out = "1.9.0"; } 27 { case = range "8.7" "8.9"; out = "1.8.0"; } 28 { case = range "8.6" "8.9"; out = "1.7.0"; } 29 { case = range "8.5" "8.7"; out = "1.6.4"; } 30 ] null; 31 release = { 32 "1.13.0".sha256 = "0j4cz2y1r1aw79snkcf1pmicgzf8swbaf9ippz0vg99a572zqzri"; 33 "1.12.0".sha256 = "1ccfny1vwgmdl91kz5xlmhq4wz078xm4z5wpd0jy5rn890dx03wp"; 34 "1.11.0".sha256 = "06a71d196wd5k4wg7khwqb7j7ifr7garhwkd54s86i0j7d6nhl3c"; 35 "1.10.0".sha256 = "1b9m6pwxxyivw7rgx82gn5kmgv2mfv3h3y0mmjcjfypi8ydkrlbv"; 36 "1.9.0".sha256 = "0lid9zaazdi3d38l8042lczb02pw5m9wq0yysiilx891hgq2p81r"; 37 "1.8.0".sha256 = "07l40is389ih8bi525gpqs3qp4yb2kl11r9c8ynk1ifpjzpnabwp"; 38 "1.7.0".sha256 = "0wnhj9nqpx2bw6n1l4i8jgrw3pjajvckvj3lr4vzjb3my2lbxdd1"; 39 "1.6.4".sha256 = "09ww48qbjsvpjmy1g9yhm0rrkq800ffq21p6fjkbwd34qvd82raz"; 40 "1.6.1".sha256 = "1ilw6vm4dlsdv9cd7kmf0vfrh2kkzr45wrqr8m37miy0byzr4p9i"; 41 }; 42 releaseRev = v: "mathcomp-${v}"; 43 44 # list of core mathcomp packages sorted by dependency order 45 packages = [ "ssreflect" "fingroup" "algebra" "solvable" "field" "character" "all" ]; 46 47 mathcomp_ = package: let 48 mathcomp-deps = if package == "single" then [] 49 else map mathcomp_ (head (splitList (pred.equal package) packages)); 50 pkgpath = if package == "single" then "mathcomp" else "mathcomp/${package}"; 51 pname = if package == "single" then "mathcomp" else "mathcomp-${package}"; 52 pkgallMake = '' 53 echo "all.v" > Make 54 echo "-I ." >> Make 55 echo "-R . mathcomp.all" >> Make 56 ''; 57 derivation = mkCoqDerivation ({ 58 inherit version pname defaultVersion release releaseRev repo owner; 59 60 nativeBuildInputs = optionals withDoc [ graphviz lua ]; 61 mlPlugin = versions.isLe "8.6" coq.coq-version; 62 extraBuildInputs = [ ncurses which ]; 63 propagatedBuildInputs = mathcomp-deps; 64 65 buildFlags = optional withDoc "doc"; 66 67 preBuild = '' 68 if [[ -f etc/utils/ssrcoqdep ]] 69 then patchShebangs etc/utils/ssrcoqdep 70 fi 71 if [[ -f etc/buildlibgraph ]] 72 then patchShebangs etc/buildlibgraph 73 fi 74 '' + '' 75 cd ${pkgpath} 76 '' + optionalString (package == "all") pkgallMake; 77 78 meta = { 79 homepage = "https://math-comp.github.io/"; 80 license = licenses.cecill-b; 81 maintainers = with maintainers; [ vbgl jwiegley cohencyril ]; 82 }; 83 } // optionalAttrs (package != "single") 84 { passthru = genAttrs packages mathcomp_; } 85 // optionalAttrs withDoc { 86 htmldoc_template = 87 fetchzip { 88 url = "https://github.com/math-comp/math-comp.github.io/archive/doc-1.12.0.zip"; 89 sha256 = "0y1352ha2yy6k2dl375sb1r68r1qi9dyyy7dyzj5lp9hxhhq69x8"; 90 }; 91 postBuild = '' 92 cp -rf _build_doc/* . 93 rm -r _build_doc 94 ''; 95 postInstall = 96 let tgt = "$out/share/coq/${coq.coq-version}/"; in 97 optionalString withDoc '' 98 mkdir -p ${tgt} 99 cp -r htmldoc ${tgt} 100 cp -r $htmldoc_template/htmldoc_template/* ${tgt}/htmldoc/ 101 ''; 102 buildTargets = "doc"; 103 extraInstallFlags = [ "-f Makefile.coq" ]; 104 }); 105 patched-derivation1 = derivation.overrideAttrs (o: 106 optionalAttrs (o.pname != null && o.pname == "mathcomp-all" && 107 o.version != null && o.version != "dev" && versions.isLt "1.7" o.version) 108 { preBuild = ""; buildPhase = ""; installPhase = "echo doing nothing"; } 109 ); 110 patched-derivation = patched-derivation1.overrideAttrs (o: 111 optionalAttrs (versions.isLe "8.7" coq.coq-version || 112 (o.version != "dev" && versions.isLe "1.7" o.version)) 113 { 114 installFlags = o.installFlags ++ [ "-f Makefile.coq" ]; 115 } 116 ); 117 in patched-derivation; 118in 119mathcomp_ (if single then "single" else "all")