|
| 1 | +{ lib, fetchzip, |
| 2 | + mkCoqDerivation, recurseIntoAttrs, single ? false, |
| 3 | + coqPackages, coq, equations, version ? null }@args: |
| 4 | +with builtins // lib; |
| 5 | +let |
| 6 | + repo = "metacoq"; |
| 7 | + owner = "MetaCoq"; |
| 8 | + defaultVersion = with versions; switch coq.coq-version [ |
| 9 | + { case = "8.11"; out = "1.0-beta2-8.11"; } |
| 10 | + { case = "8.12"; out = "1.0-beta2-8.12"; } |
| 11 | + # Do not provide 8.13 because it does not compile with equations 1.3 provided by default (only 1.2.3) |
| 12 | + # { case = "8.13"; out = "1.0-beta2-8.13"; } |
| 13 | + { case = "8.14"; out = "1.0-8.14"; } |
| 14 | + { case = "8.15"; out = "1.0-8.15"; } |
| 15 | + { case = "8.16"; out = "1.0-8.16"; } |
| 16 | + { case = "8.17"; out = "1.3.1-8.17"; } |
| 17 | + { case = "8.18"; out = "1.3.1-8.18"; } |
| 18 | + { case = "8.19"; out = "1.3.2-8.19"; } |
| 19 | + ] null; |
| 20 | + release = { |
| 21 | + # Release tarballs from GitHub or local sources for Version "dev". |
| 22 | + "1.0-beta2-8.11".sha256 = "sha256-I9YNk5Di6Udvq5/xpLSNflfjRyRH8fMnRzbo3uhpXNs="; |
| 23 | + "1.0-beta2-8.12".sha256 = "sha256-I8gpmU9rUQJh0qfp5KOgDNscVvCybm5zX4TINxO1TVA="; |
| 24 | + "1.0-beta2-8.13".sha256 = "sha256-IC56/lEDaAylUbMCfG/3cqOBZniEQk8jmI053DBO5l8="; |
| 25 | + "1.0-8.14".sha256 = "sha256-iRnaNeHt22JqxMNxOGPPycrO9EoCVjusR2s0GfON1y0="; |
| 26 | + "1.0-8.15".sha256 = "sha256-8RUC5dHNfLJtJh+IZG4nPTAVC8ZKVh2BHedkzjwLf/k="; |
| 27 | + "1.0-8.16".sha256 = "sha256-7rkCAN4PNnMgsgUiiLe2TnAliknN75s2SfjzyKCib/o="; |
| 28 | + "1.3.1-8.17".sha256 = "sha256-l0/QLC7V3zSk/FsaE2eL6tXy2BzbcI5MAk/c+FESwnc="; |
| 29 | + "1.3.1-8.18".sha256 = "sha256-L6Ym4Auwqaxv5tRmJLSVC812dxCqdUU5aN8+t5HVYzY="; |
| 30 | + "1.3.1-8.19".sha256 = "sha256-fZED/Uel1jt5XF83dR6HfyhSkfBdLkET8C/ArDgsm64="; |
| 31 | + "1.3.2-8.19".sha256 = "sha256-e5Pm1AhaQrO6JoZylSXYWmeXY033QflQuCBZhxGH8MA="; |
| 32 | + "dev".src = lib.const (lib.cleanSource ../.); |
| 33 | + }; |
| 34 | + releaseRev = v: "v${v}"; |
| 35 | + |
| 36 | + # list of core metacoq packages sorted by dependency order |
| 37 | + packages = [ "utils" "common" "template-coq" "pcuic" "safechecker" "template-pcuic" "erasure" "quotation" "safechecker-plugin" "erasure-plugin" "all" ]; |
| 38 | + |
| 39 | + template-coq = metacoq_ "template-coq"; |
| 40 | + |
| 41 | + metacoq_ = package: let |
| 42 | + metacoq-deps = if package == "single" then [] |
| 43 | + else map metacoq_ (head (splitList (pred.equal package) packages)); |
| 44 | + pkgpath = if package == "single" then "./" else "./${package}"; |
| 45 | + pname = if package == "all" then "metacoq" else "metacoq-${package}"; |
| 46 | + pkgallMake = '' |
| 47 | + mkdir all |
| 48 | + echo "all:" > all/Makefile |
| 49 | + echo "install:" >> all/Makefile |
| 50 | + '' ; |
| 51 | + derivation = (mkCoqDerivation ({ |
| 52 | + inherit version pname defaultVersion release releaseRev repo owner; |
| 53 | + |
| 54 | + mlPlugin = true; |
| 55 | + propagatedBuildInputs = [ equations coq.ocamlPackages.zarith ] ++ metacoq-deps; |
| 56 | + |
| 57 | + patchPhase = '' |
| 58 | + patchShebangs ./configure.sh |
| 59 | + patchShebangs ./template-coq/update_plugin.sh |
| 60 | + patchShebangs ./template-coq/gen-src/to-lower.sh |
| 61 | + patchShebangs ./safechecker-plugin/clean_extraction.sh |
| 62 | + patchShebangs ./erasure-plugin/clean_extraction.sh |
| 63 | + echo "CAMLFLAGS+=-w -60 # Unused module" >> ./safechecker/Makefile.plugin.local |
| 64 | + sed -i -e 's/mv $i $newi;/mv $i tmp; mv tmp $newi;/' ./template-coq/gen-src/to-lower.sh ./safechecker-plugin/clean_extraction.sh ./erasure-plugin/clean_extraction.sh |
| 65 | + '' ; |
| 66 | + |
| 67 | + configurePhase = optionalString (package == "all") pkgallMake + '' |
| 68 | + touch ${pkgpath}/metacoq-config |
| 69 | + '' + optionalString (elem package ["safechecker" "erasure" "template-pcuic" "quotation" "safechecker-plugin" "erasure-plugin"]) '' |
| 70 | + echo "-I ${template-coq}/lib/coq/${coq.coq-version}/user-contrib/MetaCoq/Template/" > ${pkgpath}/metacoq-config |
| 71 | + '' + optionalString (package == "single") '' |
| 72 | + ./configure.sh local |
| 73 | + ''; |
| 74 | + |
| 75 | + preBuild = '' |
| 76 | + cd ${pkgpath} |
| 77 | + '' ; |
| 78 | + |
| 79 | + meta = { |
| 80 | + homepage = "https://metacoq.github.io/"; |
| 81 | + license = licenses.mit; |
| 82 | + maintainers = with maintainers; [ cohencyril ]; |
| 83 | + }; |
| 84 | + } // optionalAttrs (package != "single") |
| 85 | + { passthru = genAttrs packages metacoq_; }) |
| 86 | + ).overrideAttrs (o: |
| 87 | + let requiresOcamlStdlibShims = versionAtLeast o.version "1.0-8.16" || |
| 88 | + (o.version == "dev" && (versionAtLeast coq.coq-version "8.16" || coq.coq-version == "dev")) ; |
| 89 | + in |
| 90 | + { |
| 91 | + propagatedBuildInputs = o.propagatedBuildInputs ++ optional requiresOcamlStdlibShims coq.ocamlPackages.stdlib-shims; |
| 92 | + }); |
| 93 | + in derivation; |
| 94 | +in |
| 95 | +metacoq_ (if single then "single" else "all") |
0 commit comments