ocamlPackages.elpi: use release tarball (#343266)

coqPackages.metaFetch: Adding a github artifact option

Co-authored-by: Cyril Cohen <cohen@crans.org>
This commit is contained in:
Vincent Laporte 2024-09-23 09:52:07 +02:00 committed by GitHub
parent fd97534f7e
commit 94d0d22817
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 37 additions and 32 deletions

View File

@ -23,12 +23,13 @@ The recommended way of defining a derivation for a Coq library, is to use the `c
* if it is a string of the form `owner:branch` then it tries to download the `branch` of owner `owner` for a project of the same name using the same vcs, and the `version` attribute of the resulting derivation is set to `"dev"`, additionally if the owner is not provided (i.e. if the `owner:` prefix is missing), it defaults to the original owner of the package (see below),
* if it is a string of the form `"#N"`, and the domain is github, then it tries to download the current head of the pull request `#N` from github,
* `defaultVersion` (optional). Coq libraries may be compatible with some specific versions of Coq only. The `defaultVersion` attribute is used when no `version` is provided (or if `version = null`) to select the version of the library to use by default, depending on the context. This selection will mainly depend on a `coq` version number but also possibly on other packages versions (e.g. `mathcomp`). If its value ends up to be `null`, the package is marked for removal in end-user `coqPackages` attribute set.
* `release` (optional, defaults to `{}`), lists all the known releases of the library and for each of them provides an attribute set with at least a `hash` attribute (you may put the empty string `""` in order to automatically insert a fake hash, this will trigger an error which will allow you to find the correct hash), each attribute set of the list of releases also takes optional overloading arguments for the fetcher as below (i.e.`domain`, `owner`, `repo`, `rev` assuming the default fetcher is used) and optional overrides for the result of the fetcher (i.e. `version` and `src`).
* `release` (optional, defaults to `{}`), lists all the known releases of the library and for each of them provides an attribute set with at least a `hash` attribute (you may put the empty string `""` in order to automatically insert a fake hash, this will trigger an error which will allow you to find the correct hash), each attribute set of the list of releases also takes optional overloading arguments for the fetcher as below (i.e.`domain`, `owner`, `repo`, `rev`, `artifact` assuming the default fetcher is used) and optional overrides for the result of the fetcher (i.e. `version` and `src`).
* `fetcher` (optional, defaults to a generic fetching mechanism supporting github or gitlab based infrastructures), is a function that takes at least an `owner`, a `repo`, a `rev`, and a `hash` and returns an attribute set with a `version` and `src`.
* `repo` (optional, defaults to the value of `pname`),
* `owner` (optional, defaults to `"coq-community"`).
* `domain` (optional, defaults to `"github.com"`), domains including the strings `"github"` or `"gitlab"` in their names are automatically supported, otherwise, one must change the `fetcher` argument to support them (cf `pkgs/development/coq-modules/heq/default.nix` for an example),
* `releaseRev` (optional, defaults to `(v: v)`), provides a default mapping from release names to revision hashes/branch names/tags,
* `releaseArtifact` (optional, defaults to `(v: null)`), provides a default mapping from release names to artifact names (only works for github artifact for now),
* `displayVersion` (optional), provides a way to alter the computation of `name` from `pname`, by explaining how to display version numbers,
* `namePrefix` (optional, defaults to `[ "coq" ]`), provides a way to alter the computation of `name` from `pname`, by explaining which dependencies must occur in `name`,
* `nativeBuildInputs` (optional), is a list of executables that are required to build the current derivation, in addition to the default ones (namely `which`, `dune` and `ocaml` depending on whether `useDune`, `useDuneifVersion` and `mlPlugin` are set).

View File

@ -5,7 +5,7 @@
# - The exact version can be specified through the `version` argument to
# the derivation; it defaults to the latest stable version.
{ lib, stdenv, fetchzip, writeText, pkg-config, gnumake42
{ lib, stdenv, fetchzip, fetchurl, writeText, pkg-config, gnumake42
, customOCamlPackages ? null
, ocamlPackages_4_05, ocamlPackages_4_09, ocamlPackages_4_10, ocamlPackages_4_12
, ocamlPackages_4_14
@ -62,7 +62,7 @@ let
};
releaseRev = v: "V${v}";
fetched = import ../../../../build-support/coq/meta-fetch/default.nix
{ inherit lib stdenv fetchzip; }
{ inherit lib stdenv fetchzip fetchurl; }
{ inherit release releaseRev; location = { owner = "coq"; repo = "coq";}; }
args.version;
version = fetched.version;

View File

@ -1,4 +1,4 @@
{ lib, stdenv, coqPackages, coq, which, fetchzip }@args:
{ lib, stdenv, coqPackages, coq, which, fetchzip, fetchurl }@args:
let
lib = import ./extra-lib.nix {
@ -71,7 +71,7 @@ let
"extraInstallFlags" "setCOQBIN" "mlPlugin"
"dropAttrs" "dropDerivationAttrs" "keepAttrs" ] ++ dropAttrs) keepAttrs;
fetch = import ../coq/meta-fetch/default.nix
{ inherit lib stdenv fetchzip; } ({
{ inherit lib stdenv fetchzip fetchurl; } ({
inherit release releaseRev;
location = { inherit domain owner repo; };
} // optionalAttrs (args?fetcher) {inherit fetcher;});

View File

@ -1,4 +1,4 @@
{ lib, stdenv, fetchzip }@args:
{ lib, stdenv, fetchurl, fetchzip }@args:
let
lib = import ../extra-lib.nix {
@ -28,11 +28,16 @@ let
inherit (lib.strings) match split;
default-fetcher = {domain ? "github.com", owner ? "", repo, rev, name ? "source", sha256 ? null, ...}@args:
let ext = if args?sha256 then "zip" else "tar.gz";
fmt = if args?sha256 then "zip" else "tarball";
default-fetcher = {domain ? "github.com", owner ? "", repo, rev, name ? "source", sha256 ? null, artifact ? null, ...}@args:
let kind = switch-if [
{ cond = artifact != null; out = {ext = "tbz"; fmt = "tbz"; fetchfun = fetchurl; }; }
{ cond = args?sha256 ; out = {ext = "zip"; fmt = "zip"; fetchfun = fetchzip; }; }
] {ext = "tar.gz"; fmt = "tarball"; fetchfun = builtins.fetchTarball; }; in
with kind; let
pr = match "^#(.*)$" rev;
url = switch-if [
{ cond = pr == null && (match "^github.*" domain) != null && artifact != null;
out = "https://github.com/${owner}/${repo}/releases/download/${rev}/${artifact}"; }
{ cond = pr == null && (match "^github.*" domain) != null;
out = "https://${domain}/${owner}/${repo}/archive/${rev}.${ext}"; }
{ cond = pr != null && (match "^github.*" domain) != null;
@ -42,7 +47,7 @@ let
{ cond = (match "(www.)?mpi-sws.org" domain) != null;
out = "https://www.mpi-sws.org/~${owner}/${repo}/download/${repo}-${rev}.${ext}";}
] (throw "meta-fetch: no fetcher found for domain ${domain} on ${rev}");
fetch = x: if args?sha256 then fetchzip (x // { inherit sha256; }) else builtins.fetchTarball x;
fetch = x: fetchfun (if args?sha256 then (x // { inherit sha256; }) else x);
in fetch { inherit url ; };
in
{
@ -50,8 +55,10 @@ in
location,
release ? {},
releaseRev ? (v: v),
releaseArtifact ? (v: null)
}:
let isVersion = x: isString x && match "^/.*" x == null && release?${x};
let
isVersion = x: isString x && match "^/.*" x == null && release?${x};
shortVersion = x: if (isString x && match "^/.*" x == null)
then findFirst (v: versions.majorMinor v == x) null
(sort versionAtLeast (attrNames release))
@ -71,7 +78,7 @@ switch arg [
in
{
version = rv.version or v;
src = rv.src or fetcher (location // { rev = releaseRev v; } // rv);
src = rv.src or fetcher (location // { rev = releaseRev v; artifact = releaseArtifact v; } // rv);
};
}
{ case = isString;

View File

@ -9,39 +9,36 @@
, ppxlib_0_15, ppx_deriving_0_15
, coqPackages
, version ? if lib.versionAtLeast ocaml.version "4.08" then "1.18.1"
else if lib.versionAtLeast ocaml.version "4.07" then "1.15.2" else "1.14.1"
else "1.15.2"
}:
let p5 = camlp5; in
let camlp5 = p5.override { legacy = true; }; in
let fetched = coqPackages.metaFetch ({
release."1.19.2".sha256 = "sha256-7VTUbsFVoNT6srLwcAn5WNSsWC7cVUdphKRWBHHiH5M=";
release."1.18.1".sha256 = "sha256-zgBJefQDe3JyCGbC0wvMcx/9iMVbftBJ43NPogkNeHY=";
release."1.17.0".sha256 = "sha256-DTxE8CvYl0et20pxueydI+WzraI6UPHMNvxyp2gU/+w=";
release."1.16.5".sha256 = "sha256-tKX5/cVPoBeHiUe+qn7c5FIRYCwY0AAukN7vSd/Nz9A=";
release."1.15.2".sha256 = "sha256-XgopNP83POFbMNyl2D+gY1rmqGg03o++Ngv3zJfCn2s=";
release."1.15.0".sha256 = "sha256:1ngdc41sgyzyz3i3lkzjhnj66gza5h912virkh077dyv17ysb6ar";
release."1.14.1".sha256 = "sha256-BZPVL8ymjrE9kVGyf6bpc+GA2spS5JBpkUtZi04nPis=";
release."1.13.7".sha256 = "10fnwz30bsvj7ii1vg4l1li5pd7n0qqmwj18snkdr5j9gk0apc1r";
release."1.13.5".sha256 = "02a6r23mximrdvs6kgv6rp0r2dgk7zynbs99nn7lphw2c4189kka";
release."1.13.1".sha256 = "12a9nbdvg9gybpw63lx3nw5wnxfznpraprb0wj3l68v1w43xq044";
release."1.13.0".sha256 = "0dmzy058m1mkndv90byjaik6lzzfk3aaac7v84mpmkv6my23bygr";
release."1.12.0".sha256 = "1agisdnaq9wrw3r73xz14yrq3wx742i6j8i5icjagqk0ypmly2is";
release."1.11.4".sha256 = "1m0jk9swcs3jcrw5yyw5343v8mgax238cjb03s8gc4wipw1fn9f5";
release."1.19.2".sha256 = "sha256-dBj5Ek7PWq/8Btq/dggJUqa8cUtfvbi6EWo/lJEDOU4=";
release."1.18.1".sha256 = "sha256-rrIv/mVC0Ez3nU7fpnzwduIC3tI6l73DjgAbv1gd2v0=";
release."1.17.0".sha256 = "sha256-J8FJBeaB+2HtHjrkgNzOZJngZ2AcYU+npL9Y1HNPnzo=";
release."1.15.2".sha256 = "sha256-+sQYQiN3n+dlzXzi5opOjhkJZqpkNwlHZcUjaUM6+xQ=";
release."1.15.0".sha256 = "sha256-vpQzbkDqJPCmaBmXcBnzlWGS7djW9wWv8xslkIlXgP0=";
release."1.13.7".sha256 = "sha256-0QbOEnrRCYA2mXDGRKe+QYCXSESLJvLzRW0Iq+/3P9Y=";
release."1.12.0".sha256 = "sha256-w4JzLZB8jcxw7nA7AfgU9jTZTr6IYUxPU5E2vNIFC4Q=";
release."1.11.4".sha256 = "sha256-dyzEpzokgffsF9lt+FZgUlcZEuAb70vGuHfGUtjZYIM=";
releaseRev = v: "v${v}";
releaseArtifact = v: if lib.versionAtLeast v "1.13.8"
then "elpi-${v}.tbz"
else "elpi-v${v}.tbz";
location = { domain = "github.com"; owner = "LPCIC"; repo = "elpi"; };
}) version;
in
buildDunePackage rec {
buildDunePackage {
pname = "elpi";
inherit (fetched) version src;
patches = lib.optional (version == "1.16.5")
./atd_2_10.patch;
minimalOCamlVersion = "4.04";
duneVersion = "3";
minimalOCamlVersion = "4.07";
# atdgen is both a library and executable
nativeBuildInputs = [ perl ]
@ -68,6 +65,6 @@ buildDunePackage rec {
};
postPatch = ''
substituteInPlace elpi_REPL.ml --replace "tput cols" "${ncurses}/bin/tput cols"
substituteInPlace elpi_REPL.ml --replace-warn "tput cols" "${ncurses}/bin/tput cols"
'';
}

View File

@ -1,4 +1,4 @@
{ lib, stdenv, fetchzip
{ lib, stdenv, fetchurl, fetchzip
, callPackage, newScope, recurseIntoAttrs, ocamlPackages_4_05, ocamlPackages_4_09
, ocamlPackages_4_10, ocamlPackages_4_12, ocamlPackages_4_14
, fetchpatch, makeWrapper, coq2html
@ -11,7 +11,7 @@ let
coqPackages = self // { __attrsFailEvaluation = true; recurseForDerivations = false; };
metaFetch = import ../build-support/coq/meta-fetch/default.nix
{inherit lib stdenv fetchzip; };
{inherit lib stdenv fetchzip fetchurl; };
mkCoqDerivation = lib.makeOverridable (callPackage ../build-support/coq {});
contribs = recurseIntoAttrs