|
1 | | -{ lib, fetchzip, |
2 | | - mkCoqDerivation, recurseIntoAttrs, single ? false, |
3 | | - coqPackages, coq, equations, version ? null }@args: |
4 | | -with builtins // lib; |
| 1 | +{ lib, |
| 2 | + mkCoqDerivation, single ? false, |
| 3 | + coq, equations, version ? null }@args: |
| 4 | + |
5 | 5 | let |
6 | 6 | repo = "metacoq"; |
7 | 7 | owner = "MetaCoq"; |
8 | | - defaultVersion = with versions; switch coq.coq-version [ |
| 8 | + defaultVersion = lib.switch coq.coq-version [ |
9 | 9 | { case = "8.11"; out = "1.0-beta2-8.11"; } |
10 | 10 | { case = "8.12"; out = "1.0-beta2-8.12"; } |
11 | 11 | # Do not provide 8.13 because it does not compile with equations 1.3 provided by default (only 1.2.3) |
12 | 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 = "dev"; out = "dev"; } |
| 13 | + { case = "8.14"; out = "1.1-8.14"; } |
| 14 | + { case = "8.15"; out = "1.1-8.15"; } |
| 15 | + { case = "8.16"; out = "1.1-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.3-8.19"; } |
| 19 | + { case = "8.20"; out = "1.3.4-8.20"; } |
17 | 20 | ] null; |
18 | 21 | release = { |
19 | 22 | "1.0-beta2-8.11".sha256 = "sha256-I9YNk5Di6Udvq5/xpLSNflfjRyRH8fMnRzbo3uhpXNs="; |
|
22 | 25 | "1.0-8.14".sha256 = "sha256-iRnaNeHt22JqxMNxOGPPycrO9EoCVjusR2s0GfON1y0="; |
23 | 26 | "1.0-8.15".sha256 = "sha256-8RUC5dHNfLJtJh+IZG4nPTAVC8ZKVh2BHedkzjwLf/k="; |
24 | 27 | "1.0-8.16".sha256 = "sha256-7rkCAN4PNnMgsgUiiLe2TnAliknN75s2SfjzyKCib/o="; |
| 28 | + "1.1-8.14".sha256 = "sha256-6vViCNQl6BnGgOHX3P/OLfFXN4aUfv4RbDokfz2BgQI="; |
| 29 | + "1.1-8.15".sha256 = "sha256-qCD3wFW4E+8vSVk4XoZ0EU4PVya0al+JorzS9nzmR/0="; |
| 30 | + "1.1-8.16".sha256 = "sha256-cTK4ptxpPPlqxAhasZFX3RpSlsoTZwhTqs2A3BZy9sA="; |
| 31 | + "1.2.1-8.17".sha256 = "sha256-FP4upuRsG8B5Q5FIr76t+ecRirrOUX0D1QiLq0/zMyE="; |
| 32 | + "1.2.1-8.18".sha256 = "sha256-49g5db2Bv8HpltptJdxA7zrmgNFGC6arx5h2mKHhrko="; |
| 33 | + "1.3.1-8.17".sha256 = "sha256-l0/QLC7V3zSk/FsaE2eL6tXy2BzbcI5MAk/c+FESwnc="; |
| 34 | + "1.3.1-8.18".sha256 = "sha256-L6Ym4Auwqaxv5tRmJLSVC812dxCqdUU5aN8+t5HVYzY="; |
| 35 | + "1.3.1-8.19".sha256 = "sha256-fZED/Uel1jt5XF83dR6HfyhSkfBdLkET8C/ArDgsm64="; |
| 36 | + "1.3.2-8.19".sha256 = "sha256-e5Pm1AhaQrO6JoZylSXYWmeXY033QflQuCBZhxGH8MA="; |
| 37 | + "1.3.2-8.20".sha256 = "sha256-4J7Ly4Fc2E/I6YqvzTLntVVls5t94OUOjVMKJyyJdw8="; |
| 38 | + "1.3.3-8.19".sha256 = "sha256-SBTv49zQXZ+oGvIqWM53hjBKru9prFgZRv8gVgls40k="; |
| 39 | + "1.3.4-8.20".sha256 = "sha256-ofRP0Uo48G2LBuIy/5ZLyK+iVZXleKiwfMEBD0rX9fQ="; |
25 | 40 | }; |
26 | 41 | releaseRev = v: "v${v}"; |
27 | 42 |
|
28 | | - # list of core metacoq packages sorted by dependency order |
29 | | - packages = [ "utils" "common" "template-coq" "pcuic" "safechecker" "template-pcuic" "erasure" "quotation" "safechecker-plugin" "erasure-plugin" "all" ]; |
| 43 | + # list of core metacoq packages and their dependencies |
| 44 | + packages = { |
| 45 | + "utils" = []; |
| 46 | + "common" = [ "utils" ]; |
| 47 | + "template-coq" = [ "common" ]; |
| 48 | + "pcuic" = if (lib.versionAtLeast coq.coq-version "8.17" || coq.coq-version == "dev") |
| 49 | + then [ "common" ] |
| 50 | + else [ "template-coq" ]; |
| 51 | + "safechecker" = [ "pcuic" ]; |
| 52 | + "template-pcuic" = [ "template-coq" "pcuic" ]; |
| 53 | + "erasure" = [ "safechecker" "template-pcuic" ]; |
| 54 | + "quotation" = [ "template-coq" "pcuic" "template-pcuic" ]; |
| 55 | + "safechecker-plugin" = [ "template-pcuic" "safechecker" ]; |
| 56 | + "erasure-plugin" = [ "template-pcuic" "erasure" ]; |
| 57 | + "translations" = [ "template-coq" ]; |
| 58 | + "all" = [ "safechecker-plugin" "erasure-plugin" "translations" "quotation" ]; |
| 59 | + }; |
30 | 60 |
|
31 | 61 | template-coq = metacoq_ "template-coq"; |
32 | 62 |
|
33 | 63 | metacoq_ = package: let |
34 | | - metacoq-deps = if package == "single" then [] |
35 | | - else map metacoq_ (head (splitList (pred.equal package) packages)); |
| 64 | + metacoq-deps = lib.optionals (package != "single") (map metacoq_ packages.${package}); |
36 | 65 | pkgpath = if package == "single" then "./" else "./${package}"; |
37 | 66 | pname = if package == "all" then "metacoq" else "metacoq-${package}"; |
38 | 67 | pkgallMake = '' |
39 | 68 | mkdir all |
40 | 69 | echo "all:" > all/Makefile |
41 | 70 | echo "install:" >> all/Makefile |
42 | | - '' ; |
| 71 | + ''; |
43 | 72 | derivation = (mkCoqDerivation ({ |
44 | 73 | inherit version pname defaultVersion release releaseRev repo owner; |
45 | 74 |
|
46 | 75 | mlPlugin = true; |
47 | 76 | propagatedBuildInputs = [ equations coq.ocamlPackages.zarith ] ++ metacoq-deps; |
48 | 77 |
|
49 | | - patchPhase = '' |
| 78 | + patchPhase = if lib.versionAtLeast coq.coq-version "8.17" || coq.coq-version == "dev" then '' |
50 | 79 | patchShebangs ./configure.sh |
51 | 80 | patchShebangs ./template-coq/update_plugin.sh |
52 | 81 | patchShebangs ./template-coq/gen-src/to-lower.sh |
53 | 82 | patchShebangs ./safechecker-plugin/clean_extraction.sh |
54 | 83 | patchShebangs ./erasure-plugin/clean_extraction.sh |
55 | 84 | echo "CAMLFLAGS+=-w -60 # Unused module" >> ./safechecker/Makefile.plugin.local |
56 | 85 | 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 |
57 | | - '' ; |
| 86 | + '' else '' |
| 87 | + patchShebangs ./configure.sh |
| 88 | + patchShebangs ./template-coq/update_plugin.sh |
| 89 | + patchShebangs ./template-coq/gen-src/to-lower.sh |
| 90 | + patchShebangs ./pcuic/clean_extraction.sh |
| 91 | + patchShebangs ./safechecker/clean_extraction.sh |
| 92 | + patchShebangs ./erasure/clean_extraction.sh |
| 93 | + echo "CAMLFLAGS+=-w -60 # Unused module" >> ./safechecker/Makefile.plugin.local |
| 94 | + sed -i -e 's/mv $i $newi;/mv $i tmp; mv tmp $newi;/' ./template-coq/gen-src/to-lower.sh ./pcuic/clean_extraction.sh ./safechecker/clean_extraction.sh ./erasure/clean_extraction.sh |
| 95 | + ''; |
58 | 96 |
|
59 | | - configurePhase = optionalString (package == "all") pkgallMake + '' |
| 97 | + configurePhase = lib.optionalString (package == "all") pkgallMake + '' |
60 | 98 | touch ${pkgpath}/metacoq-config |
61 | | - '' + optionalString (elem package ["safechecker" "erasure" "template-pcuic" "quotation" "safechecker-plugin" "erasure-plugin"]) '' |
| 99 | + '' + lib.optionalString (lib.elem package ["erasure" "template-pcuic" "quotation" "safechecker-plugin" "erasure-plugin" "translations"]) '' |
62 | 100 | echo "-I ${template-coq}/lib/coq/${coq.coq-version}/user-contrib/MetaCoq/Template/" > ${pkgpath}/metacoq-config |
63 | | - '' + optionalString (package == "single") '' |
| 101 | + '' + lib.optionalString (package == "single") '' |
64 | 102 | ./configure.sh local |
65 | 103 | ''; |
66 | 104 |
|
67 | 105 | preBuild = '' |
68 | 106 | cd ${pkgpath} |
69 | | - '' ; |
| 107 | + ''; |
70 | 108 |
|
71 | 109 | meta = { |
72 | 110 | homepage = "https://metacoq.github.io/"; |
73 | | - license = licenses.mit; |
74 | | - maintainers = with maintainers; [ cohencyril ]; |
| 111 | + license = lib.licenses.mit; |
| 112 | + maintainers = with lib.maintainers; [ cohencyril ]; |
75 | 113 | }; |
76 | | - } // optionalAttrs (package != "single") |
77 | | - { passthru = genAttrs packages metacoq_; }) |
78 | | - ).overrideAttrs (o: |
79 | | - let requiresOcamlStdlibShims = versionAtLeast o.version "1.0-8.16" || |
80 | | - (o.version == "dev" && (versionAtLeast coq.coq-version "8.16" || coq.coq-version == "dev")) ; |
81 | | - in |
82 | | - { |
83 | | - propagatedBuildInputs = o.propagatedBuildInputs ++ optional requiresOcamlStdlibShims coq.ocamlPackages.stdlib-shims; |
84 | | - }); |
85 | | - in derivation; |
| 114 | + } // lib.optionalAttrs (package != "single") |
| 115 | + { passthru = lib.mapAttrs (package: deps: metacoq_ package) packages; }) |
| 116 | + ).overrideAttrs (o: |
| 117 | + let requiresOcamlStdlibShims = lib.versionAtLeast o.version "1.0-8.16" || |
| 118 | + (o.version == "dev" && (lib.versionAtLeast coq.coq-version "8.16" || coq.coq-version == "dev")) ; |
| 119 | + in |
| 120 | + { |
| 121 | + propagatedBuildInputs = o.propagatedBuildInputs ++ lib.optional requiresOcamlStdlibShims coq.ocamlPackages.stdlib-shims; |
| 122 | + }); |
| 123 | + # utils, common, template-pcuic, quotation, safechecker-plugin, and erasure-plugin |
| 124 | + # packages didn't exist before 1.2, so bulding nothing in that case |
| 125 | + patched-derivation = derivation.overrideAttrs (o: |
| 126 | + lib.optionalAttrs (o.pname != null && |
| 127 | + lib.elem package [ "utils" "common" "template-pcuic" "quotation" "safechecker-plugin" "erasure-plugin" ] && |
| 128 | + o.version != null && o.version != "dev" && lib.versions.isLt "1.2" o.version) |
| 129 | + { patchPhase = ""; configurePhase = ""; preBuild = ""; buildPhase = "echo doing nothing"; installPhase = "echo doing nothing"; } |
| 130 | + ); |
| 131 | + in patched-derivation; |
86 | 132 | in |
87 | 133 | metacoq_ (if single then "single" else "all") |
0 commit comments