···11-# Coq {#sec-language-coq}
11+# Coq and coq packages {#sec-language-coq}
2233-Coq libraries should be installed in `$(out)/lib/coq/${coq.coq-version}/user-contrib/`. Such directories are automatically added to the `$COQPATH` environment variable by the hook defined in the Coq derivation.
33+## Coq derivation: `coq`
4455-Some extensions (plugins) might require OCaml and sometimes other OCaml packages. The `coq.ocamlPackages` attribute can be used to depend on the same package set Coq was built against.
55+The Coq derivation is overridable through the `coq.override overrides`, where overrides is an attribute set which contains the arguments to override. We recommend overriding either of the following
66++ `version` (optional, defaults to the latest version of Coq selected for nixpkgs, see `pkgs/top-level/coq-packages` to witness this choice), which follows the conventions explained in the `coqPackages` section below,
77++ `customOCamlPackage` (optional, defaults to `null`, which lets Coq choose a version automatically), which can be set to any of the ocaml packages attribute of `ocaml-ng` (such as `ocaml-ng.ocamlPackages_4_10` which is the default for Coq 8.11 for example).
88++ `coq-version` (optional, defaults to the short version e.g. "8.10"), is a version number of the form "x.y" that indicates which Coq's version build behavior to mimic when using a source which is not a release. E.g. `coq.override { version = "d370a9d1328a4e1cdb9d02ee032f605a9d94ec7a"; coq-version = "8.10"; }`.
99+1010+## Coq packages attribute sets: `coqPackages`
1111+1212+The recommended way of defining a derivation for a Coq library, is to use the `coqPackages.mkCoqDerivation` function, which is essentially a specialization of `mkDerivation` taking into account most of the specifics of Coq libraries. The following attributes are supported:
1313+- `pname` (required) is the name of the package,
1414+- `version` (optional, defaults to `null`), is the version to fetch and build,
1515+ this attribute is interpreted in several ways depending on its type and pattern:
1616+ + if it is a known released version string, i.e. from the `release` attribute below, the according release is picked, and the `version` attribute of the resulting derivation is set to this release string,
1717+ + if it is a majorMinor `"x.y"` prefix of a known released version (as defined above), then the latest `"x.y.z"` known released version is selected (for the ordering given by `versionAtLeast`),
1818+ + if it is a path or a string representing an absolute path (i.e. starting with `"/"`), the provided path is selected as a source, and the `version` attribute of the resulting derivation is set to `"dev"`,
1919+ + 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),
2020+ + 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,
2121+- `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.
2222+- `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 `sha256` attribute (you may use the shell command `nix-prefetch-url --unpack <archive-url>` to find it, where `<archive-url>` is for example `https://github.com/owner/repo/archive/version.tar.gz`), 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`).
2323+- `fetcher` (optional, default 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 `sha256` and returns an attribute set with a `version` and `src`.
2424+- `repo` (optional, defaults to the value of `pname`),
2525+- `owner` (optional, defaults to `"coq-community"`).
2626+- `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),
2727+- `releaseRev` (optional, defaults to `(v: v)`), provides a default mapping from release names to revision hashes/branch names/tags,
2828+- `displayVersion` (optional), provides a way to alter the computation of `name` from `pname`, by explaining how to display version numbers,
2929+- `namePrefix` (optional), provides a way to alter the computation of `name` from `pname`, by explaining which dependencies must occur in `name`,
3030+- `extraBuildInputs` (optional), by default `buildInputs` just contains `coq`, this allows to add more build inputs,
3131+- `mlPlugin` (optional, defaults to `false`). Some extensions (plugins) might require OCaml and sometimes other OCaml packages. Standard dependencies can be added by setting the current option to `true`. For a finer grain control, the `coq.ocamlPackages` attribute can be used in `extraBuildInputs` to depend on the same package set Coq was built against.
3232+- `enableParallelBuilding` (optional, defaults to `true`), since it is activated by default, we provide a way to disable it.
3333+- `extraInstallFlags` (optional), allows to extend `installFlags` which initializes the variable `COQMF_COQLIB` so as to install in the proper subdirectory. Indeed Coq libraries should be installed in `$(out)/lib/coq/${coq.coq-version}/user-contrib/`. Such directories are automatically added to the `$COQPATH` environment variable by the hook defined in the Coq derivation.
3434+- `setCOQBIN` (optional, defaults to `true`), by default, the environment variable `$COQBIN` is set to the current Coq's binary, but one can disable this behavior by setting it to `false`,
3535+- `useMelquiondRemake` (optional, default to `null`) is an attribute set, which, if given, overloads the `preConfigurePhases`, `configureFlags`, `buildPhase`, and `installPhase` attributes of the derivation for a specific use in libraries using `remake` as set up by Guillaume Melquiond for `flocq`, `gappalib`, `interval`, and `coquelicot` (see the corresponding derivation for concrete examples of use of this option). For backward compatibility, the attribute `useMelquiondRemake.logpath` must be set to the logical root of the library (otherwise, one can pass `useMelquiondRemake = {}` to activate this without backward compatibility).
3636+- `dropAttrs`, `keepAttrs`, `dropDerivationAttrs` are all optional and allow to tune which attribute is added or removed from the final call to `mkDerivation`.
63777-Coq libraries may be compatible with some specific versions of Coq only. The `compatibleCoqVersions` attribute is used to precisely select those versions of Coq that are compatible with this derivation.
3838+It also takes other standard `mkDerivation` attributes, they are added as such, except for `meta` which extends an automatically computed `meta` (where the `platform` is the same as `coq` and the homepage is automatically computed).
83999-Here is a simple package example. It is a pure Coq library, thus it depends on Coq. It builds on the Mathematical Components library, thus it also takes `mathcomp` as `buildInputs`. Its `Makefile` has been generated using `coq_makefile` so we only have to set the `$COQLIB` variable at install time.
4040+Here is a simple package example. It is a pure Coq library, thus it depends on Coq. It builds on the Mathematical Components library, thus it also takes some `mathcomp` derivations as `extraBuildInputs`.
10411142```nix
1212-{ stdenv, fetchFromGitHub, coq, mathcomp }:
1313-1414-stdenv.mkDerivation rec {
1515- name = "coq${coq.coq-version}-multinomials-${version}";
1616- version = "1.0";
1717- src = fetchFromGitHub {
1818- owner = "math-comp";
1919- repo = "multinomials";
2020- rev = version;
2121- sha256 = "1qmbxp1h81cy3imh627pznmng0kvv37k4hrwi2faa101s6bcx55m";
4343+{ coq, mkCoqDerivation, mathcomp, mathcomp-finmap, mathcomp-bigenough,
4444+ lib, version ? null }:
4545+with lib; mkCoqDerivation {
4646+ /* namePrefix leads to e.g. `name = coq8.11-mathcomp1.11-multinomials-1.5.2` */
4747+ namePrefix = [ "coq" "mathcomp" ];
4848+ pname = "multinomials";
4949+ owner = "math-comp";
5050+ inherit version;
5151+ defaultVersion = with versions; switch [ coq.version mathcomp.version ] [
5252+ { cases = [ (range "8.7" "8.12") "1.11.0" ]; out = "1.5.2"; }
5353+ { cases = [ (range "8.7" "8.11") (range "1.8" "1.10") ]; out = "1.5.0"; }
5454+ { cases = [ (range "8.7" "8.10") (range "1.8" "1.10") ]; out = "1.4"; }
5555+ { cases = [ "8.6" (range "1.6" "1.7") ]; out = "1.1"; }
5656+ ] null;
5757+ release = {
5858+ "1.5.2".sha256 = "15aspf3jfykp1xgsxf8knqkxv8aav2p39c2fyirw7pwsfbsv2c4s";
5959+ "1.5.1".sha256 = "13nlfm2wqripaq671gakz5mn4r0xwm0646araxv0nh455p9ndjs3";
6060+ "1.5.0".sha256 = "064rvc0x5g7y1a0nip6ic91vzmq52alf6in2bc2dmss6dmzv90hw";
6161+ "1.5.0".rev = "1.5";
6262+ "1.4".sha256 = "0vnkirs8iqsv8s59yx1fvg1nkwnzydl42z3scya1xp1b48qkgn0p";
6363+ "1.3".sha256 = "0l3vi5n094nx3qmy66hsv867fnqm196r8v605kpk24gl0aa57wh4";
6464+ "1.2".sha256 = "1mh1w339dslgv4f810xr1b8v2w7rpx6fgk9pz96q0fyq49fw2xcq";
6565+ "1.1".sha256 = "1q8alsm89wkc0lhcvxlyn0pd8rbl2nnxg81zyrabpz610qqjqc3s";
6666+ "1.0".sha256 = "1qmbxp1h81cy3imh627pznmng0kvv37k4hrwi2faa101s6bcx55m";
2267 };
23682424- buildInputs = [ coq ];
2525- propagatedBuildInputs = [ mathcomp ];
2626-2727- installFlags = "COQLIB=$(out)/lib/coq/${coq.coq-version}/";
6969+ propagatedBuildInputs =
7070+ [ mathcomp.ssreflect mathcomp.algebra mathcomp-finmap mathcomp-bigenough ];
28712972 meta = {
3073 description = "A Coq/SSReflect Library for Monoidal Rings and Multinomials";
3131- inherit (src.meta) homepage;
3232- license = stdenv.lib.licenses.cecill-b;
3333- inherit (coq.meta) platforms;
3434- };
3535-3636- passthru = {
3737- compatibleCoqVersions = v: builtins.elem v [ "8.5" "8.6" "8.7" ];
7474+ license = licenses.cecill-c;
3875 };
3976}
4077```
···11+{ lib }:
22+with builtins; with lib; recursiveUpdate lib (rec {
33+44+ versions =
55+ let
66+ truncate = n: v: concatStringsSep "." (take n (splitVersion v));
77+ opTruncate = op: v0: v: let n = length (splitVersion v0); in
88+ op (truncate n v) (truncate n v0);
99+ in rec {
1010+1111+ /* Get string of the first n parts of a version string.
1212+1313+ Example:
1414+ - truncate 2 "1.2.3-stuff"
1515+ => "1.2"
1616+1717+ - truncate 4 "1.2.3-stuff"
1818+ => "1.2.3.stuff"
1919+ */
2020+2121+ inherit truncate;
2222+2323+ /* Get string of the first three parts (major, minor and patch)
2424+ of a version string.
2525+2626+ Example:
2727+ majorMinorPatch "1.2.3-stuff"
2828+ => "1.2.3"
2929+ */
3030+ majorMinorPatch = truncate 3;
3131+3232+ /* Version comparison predicates,
3333+ - isGe v0 v <-> v is greater or equal than v0 [*]
3434+ - isLe v0 v <-> v is lesser or equal than v0 [*]
3535+ - isGt v0 v <-> v is strictly greater than v0 [*]
3636+ - isLt v0 v <-> v is strictly lesser than v0 [*]
3737+ - isEq v0 v <-> v is equal to v0 [*]
3838+ - range low high v <-> v is between low and high [**]
3939+4040+ [*] truncating v to the same number of digits as v0
4141+ [**] truncating v to low for the lower bound and high for the upper bound
4242+4343+ Examples:
4444+ - isGe "8.10" "8.10.1"
4545+ => true
4646+ - isLe "8.10" "8.10.1"
4747+ => true
4848+ - isGt "8.10" "8.10.1"
4949+ => false
5050+ - isGt "8.10.0" "8.10.1"
5151+ => true
5252+ - isEq "8.10" "8.10.1"
5353+ => true
5454+ - range "8.10" "8.11" "8.11.1"
5555+ => true
5656+ - range "8.10" "8.11+" "8.11.0"
5757+ => false
5858+ - range "8.10" "8.11+" "8.11+beta1"
5959+ => false
6060+6161+ */
6262+ isGe = opTruncate versionAtLeast;
6363+ isGt = opTruncate (flip versionOlder);
6464+ isLe = opTruncate (flip versionAtLeast);
6565+ isLt = opTruncate versionOlder;
6666+ isEq = opTruncate pred.equal;
6767+ range = low: high: pred.inter (versions.isGe low) (versions.isLe high);
6868+ };
6969+7070+ /* Returns a list of list, splitting it using a predicate.
7171+ This is analoguous to builtins.split sep list,
7272+ with a predicate as a separator and a list instead of a string.
7373+7474+ Type: splitList :: (a -> bool) -> [a] -> [[a]]
7575+7676+ Example:
7777+ splitList (x: x == "x") [ "y" "x" "z" "t" ]
7878+ => [ [ "y" ] "x" [ "z" "t" ] ]
7979+ */
8080+ splitList = pred: l: # put in file lists
8181+ let loop = (vv: v: l: if l == [] then vv ++ [v]
8282+ else let hd = head l; tl = tail l; in
8383+ if pred hd then loop (vv ++ [ v hd ]) [] tl else loop vv (v ++ [hd]) tl);
8484+ in loop [] [] l;
8585+8686+ pred = {
8787+ /* Predicate intersection, union, and complement */
8888+ inter = p: q: x: p x && q x;
8989+ union = p: q: x: p x || q x;
9090+ compl = p: x: ! p x;
9191+ true = p: true;
9292+ false = p: false;
9393+9494+ /* predicate "being equal to y" */
9595+ equal = y: x: x == y;
9696+ };
9797+9898+ /* Emulate a "switch - case" construct,
9999+ instead of relying on `if then else if ...` */
100100+ /* Usage:
101101+ ```nix
102102+ switch-if [
103103+ if-clause-1
104104+ ..
105105+ if-clause-k
106106+ ] default-out
107107+ ```
108108+ where a if-clause has the form `{ cond = b; out = r; }`
109109+ the first branch such as `b` is true */
110110+111111+ switch-if = c: d: (findFirst (getAttr "cond") {} c).out or d;
112112+113113+ /* Usage:
114114+ ```nix
115115+ switch x [
116116+ simple-clause-1
117117+ ..
118118+ simple-clause-k
119119+ ] default-out
120120+ ```
121121+ where a simple-clause has the form `{ case = p; out = r; }`
122122+ the first branch such as `p x` is true
123123+ or
124124+ ```nix
125125+ switch [ x1 .. xn ] [
126126+ complex-clause-1
127127+ ..
128128+ complex-clause-k
129129+ ] default-out
130130+ ```
131131+ where a complex-clause is either a simple-clause
132132+ or has the form { cases = [ p1 .. pn ]; out = r; }
133133+ in which case the first branch such as all `pi x` are true
134134+135135+ if the variables p are not functions,
136136+ they are converted to a equal p
137137+ if out is missing the default-out is taken */
138138+139139+ switch = var: clauses: default: with pred; let
140140+ compare = f: if isFunction f then f else equal f;
141141+ combine = cl: var:
142142+ if cl?case then compare cl.case var
143143+ else all (equal true) (zipListsWith compare cl.cases var); in
144144+ switch-if (map (cl: { cond = combine cl var; inherit (cl) out; }) clauses) default;
145145+})
+66
pkgs/build-support/coq/meta-fetch/default.nix
···11+{ stdenv, fetchzip }@args:
22+let lib = import ../extra-lib.nix {inherit (args.stdenv) lib;}; in
33+with builtins; with lib;
44+let
55+ default-fetcher = {domain ? "github.com", owner ? "", repo, rev, name ? "source", sha256 ? null, ...}@args:
66+ let ext = if args?sha256 then "zip" else "tar.gz";
77+ fmt = if args?sha256 then "zip" else "tarball";
88+ pr = match "^#(.*)$" rev;
99+ url = switch-if [
1010+ { cond = isNull pr && !isNull (match "^github.*" domain);
1111+ out = "https://${domain}/${owner}/${repo}/archive/${rev}.${ext}"; }
1212+ { cond = !isNull pr && !isNull (match "^github.*" domain);
1313+ out = "https://api.${domain}/repos/${owner}/${repo}/${fmt}/pull/${head pr}/head"; }
1414+ { cond = isNull pr && !isNull (match "^gitlab.*" domain);
1515+ out = "https://${domain}/${owner}/${repo}/-/archive/${rev}/${repo}-${rev}.${ext}"; }
1616+ { cond = !isNull (match "(www.)?mpi-sws.org" domain);
1717+ out = "https://www.mpi-sws.org/~${owner}/${repo}/download/${repo}-${rev}.${ext}";}
1818+ ] (throw "meta-fetch: no fetcher found for domain ${domain} on ${rev}");
1919+ fetch = x: if args?sha256 then fetchzip (x // { inherit sha256; }) else fetchTarball x;
2020+ in fetch { inherit url ; };
2121+in
2222+{
2323+ fetcher ? default-fetcher,
2424+ location,
2525+ release ? {},
2626+ releaseRev ? (v: v),
2727+}:
2828+let isVersion = x: isString x && match "^/.*" x == null && release?${x};
2929+ shortVersion = x: if (isString x && match "^/.*" x == null)
3030+ then findFirst (v: versions.majorMinor v == x) null
3131+ (sort versionAtLeast (attrNames release))
3232+ else null;
3333+ isShortVersion = x: shortVersion x != null;
3434+ isPathString = x: isString x && match "^/.*" x != null && pathExists x; in
3535+arg:
3636+switch arg [
3737+ { case = isNull; out = { version = "broken"; src = ""; broken = true; }; }
3838+ { case = isPathString; out = { version = "dev"; src = arg; }; }
3939+ { case = pred.union isVersion isShortVersion;
4040+ out = let v = if isVersion arg then arg else shortVersion arg; in
4141+ if !release.${v}?sha256 then throw "meta-fetch: a sha256 must be provided for each release"
4242+ else {
4343+ version = release.${v}.version or v;
4444+ src = release.${v}.src or fetcher (location // { rev = releaseRev v; } // release.${v});
4545+ };
4646+ }
4747+ { case = isString;
4848+ out = let
4949+ splitted = filter isString (split ":" arg);
5050+ rev = last splitted;
5151+ has-owner = length splitted > 1;
5252+ version = "dev"; in {
5353+ inherit version;
5454+ src = fetcher (location // { inherit rev; } //
5555+ (optionalAttrs has-owner { owner = head splitted; }));
5656+ }; }
5757+ { case = isAttrs;
5858+ out = let
5959+ { version = arg.version or "dev";
6060+ src = (arg.fetcher or fetcher) (location // (arg.location or {}));
6161+ }; }
6262+ { case = isPath;
6363+ out = {
6464+ version = "dev" ;
6565+ src = builtins.path {path = arg; name = location.name or "source";}; }; }
6666+] (throw "not a valid source description")
···11-#############################
22-# Main derivation: mathcomp #
33-########################################################################
44-# This file mainly provides the `mathcomp` derivation, which is #
55-# essentially a meta-package containing all core mathcomp libraries #
66-# (ssreflect fingroup algebra solvable field character). They can be #
77-# accessed individually through the paththrough attributes of mathcomp #
88-# bearing the same names (mathcomp.ssreflect, etc). #
99-# #
1010-# Do not use overrideAttrs, but overrideMathcomp instead, which #
1111-# regenerate a full mathcomp derivation with sub-derivations, and #
1212-# behave the same as `mathcomp_`, described below. #
1313-########################################################################
11+############################################################################
22+# This file mainly provides the `mathcomp` derivation, which is #
33+# essentially a meta-package containing all core mathcomp libraries #
44+# (ssreflect fingroup algebra solvable field character). They can be #
55+# accessed individually through the passthrough attributes of mathcomp #
66+# bearing the same names (mathcomp.ssreflect, etc). #
77+############################################################################
88+# Compiling a custom version of mathcomp using `mathcomp.override`. #
99+# This is the replacement for the former `mathcomp_ config` function. #
1010+# See the documentation at doc/languages-frameworks/coq.section.md. #
1111+############################################################################
14121515-############################################################
1616-# Compiling a custom version of mathcomp using `mathcomp_` #
1717-##############################################################################
1818-# The prefered way to compile a custom version of mathcomp (other than a #
1919-# released version which should be added to `mathcomp-config-initial` #
2020-# and pushed to nixpkgs), is to apply the function `coqPackages.mathcomp_` #
2121-# to either: #
2222-# - a string without slash, which is interpreted as a github revision, #
2323-# i.e. either a tag, a branch or a commit hash #
2424-# - a string with slashes "owner/p_1/.../p_n", which is interpreted as #
2525-# github owner "owner" and revision "p_1/.../p_n". #
2626-# - a path which is interpreted as a local source for the repository, #
2727-# the name of the version is taken to be the basename of the path #
2828-# i.e. if the path is /home/you/git/package/branch/, #
2929-# then "branch" is the name of the version #
3030-# - an attribute set which overrides some attributes (e.g. the src) #
3131-# if the version is updated, the name is automatically regenerated using #
3232-# the conventional schema "coq${coq.coq-version}-${pkgname}-${version}" #
3333-# - a "standard" override function (old: new_attrs) to override the default #
3434-# attribute set, so that you can use old.${field} to patch the derivation. #
3535-##############################################################################
3636-3737-#########################################################################
3838-# Example of use: https://github.com/math-comp/math-comp/wiki/Using-nix #
3939-#########################################################################
4040-4141-#################################
4242-# Adding a new mathcomp version #
4343-#############################################################################
4444-# When adding a new version of mathcomp, add an attribute to `sha256` (use #
4545-# ```sh #
4646-# nix-prefetch-url --unpack #
4747-# https://github.com/math-comp/math-comp/archive/version.tar.gz #
4848-# ``` #
4949-# to get the corresponding `sha256`) and to `coq-version` (read the release #
5050-# notes to check which versions of coq it is compatible with). Then add #
5151-# it in `preference version`, if not all mathcomp-extra packages are #
5252-# ready, you might want to give new release secondary priority. #
5353-#############################################################################
5454-5555-5656-{ stdenv, fetchFromGitHub, ncurses, which, graphviz,
5757- recurseIntoAttrs, withDoc ? false,
5858- coqPackages,
5959- mathcomp_, mathcomp, mathcomp-config,
6060-}:
6161-with builtins // stdenv.lib;
1313+{ lib, ncurses, which, graphviz, lua,
1414+ mkCoqDerivation, recurseIntoAttrs, withDoc ? false, single ? false,
1515+ coqPackages, coq, ocamlPackages, version ? null }@args:
1616+with builtins // lib;
6217let
6363- mathcomp-config-initial = rec {
6464- #######################################################################
6565- # CONFIGURATION (please edit this), it is exported as mathcomp-config #
6666- #######################################################################
6767- # sha256 of released mathcomp versions
6868- sha256 = {
6969- "1.12.0" = "1ccfny1vwgmdl91kz5xlmhq4wz078xm4z5wpd0jy5rn890dx03wp";
7070- "1.11.0" = "06a71d196wd5k4wg7khwqb7j7ifr7garhwkd54s86i0j7d6nhl3c";
7171- "1.11+beta1" = "12i3zznwajlihzpqsiqniv20rklj8d8401lhd241xy4s21fxkkjm";
7272- "1.10.0" = "1b9m6pwxxyivw7rgx82gn5kmgv2mfv3h3y0mmjcjfypi8ydkrlbv";
7373- "1.9.0" = "0lid9zaazdi3d38l8042lczb02pw5m9wq0yysiilx891hgq2p81r";
7474- "1.8.0" = "07l40is389ih8bi525gpqs3qp4yb2kl11r9c8ynk1ifpjzpnabwp";
7575- "1.7.0" = "0wnhj9nqpx2bw6n1l4i8jgrw3pjajvckvj3lr4vzjb3my2lbxdd1";
7676- "1.6.1" = "1ilw6vm4dlsdv9cd7kmf0vfrh2kkzr45wrqr8m37miy0byzr4p9i";
7777- };
7878- # versions of coq compatible with released mathcomp versions
7979- coq-versions = {
8080- "1.12.0" = flip elem [ "8.13" ];
8181- "1.11.0" = flip elem [ "8.7" "8.8" "8.9" "8.10" "8.11" "8.12" ];
8282- "1.11+beta1" = flip elem [ "8.7" "8.8" "8.9" "8.10" "8.11" "8.12" ];
8383- "1.10.0" = flip elem [ "8.7" "8.8" "8.9" "8.10" "8.11" ];
8484- "1.9.0" = flip elem [ "8.7" "8.8" "8.9" "8.10" ];
8585- "1.8.0" = flip elem [ "8.7" "8.8" "8.9" ];
8686- "1.7.0" = flip elem [ "8.6" "8.7" "8.8" "8.9" ];
8787- "1.6.1" = flip elem [ "8.5"];
8888- };
8989-9090- # sets the default version of mathcomp given a version of Coq
9191- # this is currently computed using version-perference below
9292- # but it can be set to a fixed version number
9393- preferred-version = let v = head (
9494- filter (mc: mathcomp-config.coq-versions.${mc} coq.coq-version)
9595- mathcomp-config.version-preferences ++ ["0.0.0"]);
9696- in if v == "0.0.0" then head mathcomp-config.version-preferences else v;
9797-9898- # mathcomp preferred versions by decreasing order
9999- # (the first version in the list will be tried first)
100100- version-preferences =
101101- [ "1.12.0" "1.10.0" "1.11.0" "1.9.0" "1.8.0" "1.7.0" "1.6.1" ];
102102-103103- # list of core mathcomp packages sorted by dependency order
104104- packages = _version: # unused in current versions of mathcomp
105105- # because the following list of packages is fixed for
106106- # all versions of mathcomp up to 1.11.0
107107- [ "ssreflect" "fingroup" "algebra" "solvable" "field" "character" "all" ];
108108-109109- # compute the dependencies of the core package pkg
110110- # (assuming the total ordering above, change if necessary)
111111- deps = version: pkg: if pkg == "single" then [] else
112112- (pred-split-list (x: x == pkg) (mathcomp-config.packages version)).left;
113113- };
114114-115115- ##############################################################
116116- # COMPUTED using the configuration above (edit with caution) #
117117- ##############################################################
118118-119119- # generic split function (TODO: move to lib?)
120120- pred-split-list = pred: l:
121121- let loop = v: l: if l == [] then {left = v; right = [];}
122122- else let hd = builtins.head l; tl = builtins.tail l; in
123123- if pred hd then {left = v; right = tl;} else loop (v ++ [hd]) tl;
124124- in loop [] l;
125125-126126- pkgUp = l: r: l // r // {
127127- meta = (l.meta or {}) // (r.meta or {});
128128- passthru = (l.passthru or {}) // (r.passthru or {});
1818+ repo = "math-comp";
1919+ owner = "math-comp";
2020+ withDoc = single && (args.withDoc or false);
2121+ defaultVersion = with versions; switch coq.coq-version [
2222+ { case = isGe "8.13"; out = "1.12.0"; } # lower version of coq to 8.10 when all mathcomp packages are ported
2323+ { case = range "8.7" "8.12"; out = "1.11.0"; }
2424+ { case = range "8.7" "8.11"; out = "1.10.0"; }
2525+ { case = range "8.7" "8.11"; out = "1.9.0"; }
2626+ { case = range "8.7" "8.9"; out = "1.8.0"; }
2727+ { case = range "8.6" "8.9"; out = "1.7.0"; }
2828+ { case = range "8.5" "8.7"; out = "1.6.4"; }
2929+ ] null;
3030+ release = {
3131+ "1.12.0".sha256 = "1ccfny1vwgmdl91kz5xlmhq4wz078xm4z5wpd0jy5rn890dx03wp";
3232+ "1.11.0".sha256 = "06a71d196wd5k4wg7khwqb7j7ifr7garhwkd54s86i0j7d6nhl3c";
3333+ "1.10.0".sha256 = "1b9m6pwxxyivw7rgx82gn5kmgv2mfv3h3y0mmjcjfypi8ydkrlbv";
3434+ "1.9.0".sha256 = "0lid9zaazdi3d38l8042lczb02pw5m9wq0yysiilx891hgq2p81r";
3535+ "1.8.0".sha256 = "07l40is389ih8bi525gpqs3qp4yb2kl11r9c8ynk1ifpjzpnabwp";
3636+ "1.7.0".sha256 = "0wnhj9nqpx2bw6n1l4i8jgrw3pjajvckvj3lr4vzjb3my2lbxdd1";
3737+ "1.6.4".sha256 = "09ww48qbjsvpjmy1g9yhm0rrkq800ffq21p6fjkbwd34qvd82raz";
3838+ "1.6.1".sha256 = "1ilw6vm4dlsdv9cd7kmf0vfrh2kkzr45wrqr8m37miy0byzr4p9i";
12939 };
4040+ releaseRev = v: "mathcomp-${v}";
13041131131- coq = coqPackages.coq;
132132- mathcomp-deps = mathcomp-config.deps mathcomp.config.preferred-version;
4242+ # list of core mathcomp packages sorted by dependency order
4343+ packages = [ "ssreflect" "fingroup" "algebra" "solvable" "field" "character" "all" ];
13344134134- # default set of attributes given a 'package' name.
135135- # this attribute set will be extended using toOverrideFun
136136- default-attrs = package:
137137- let
4545+ mathcomp_ = package: let
4646+ mathcomp-deps = if package == "single" then []
4747+ else map mathcomp_ (head (splitList (pred.equal package) packages));
13848 pkgpath = if package == "single" then "mathcomp" else "mathcomp/${package}";
139139- pkgname = if package == "single" then "mathcomp" else "mathcomp-${package}";
4949+ pname = if package == "single" then "mathcomp" else "mathcomp-${package}";
14050 pkgallMake = ''
14151 echo "all.v" > Make
14252 echo "-I ." >> Make
14353 echo "-R . mathcomp.all" >> Make
14454 '';
145145- in
146146- rec {
147147- version = "master";
148148- name = "coq${coq.coq-version}-${pkgname}-${version}";
5555+ derivation = mkCoqDerivation ({
5656+ inherit version pname defaultVersion release releaseRev repo owner;
14957150150- nativeBuildInputs = optionals withDoc [ graphviz ];
151151- buildInputs = [ ncurses which ] ++ (with coq.ocamlPackages; [ ocaml findlib camlp5 ]);
152152- propagatedBuildInputs = [ coq ];
153153- enableParallelBuilding = true;
5858+ nativeBuildInputs = optional withDoc graphviz;
5959+ mlPlugin = versions.isLe "8.6" coq.coq-version;
6060+ extraBuildInputs = [ ncurses which ] ++ optional withDoc lua;
6161+ propagatedBuildInputs = mathcomp-deps;
1546215563 buildFlags = optional withDoc "doc";
15664157157- COQBIN = "${coq}/bin/";
158158-15965 preBuild = ''
16066 patchShebangs etc/utils/ssrcoqdep || true
6767+ '' + ''
16168 cd ${pkgpath}
16269 '' + optionalString (package == "all") pkgallMake;
16370164164- installPhase = ''
165165- make -f Makefile.coq COQLIB=$out/lib/coq/${coq.coq-version}/ install
166166- '' + optionalString withDoc ''
167167- make -f Makefile.coq install-doc DOCDIR=$out/share/coq/${coq.coq-version}/
168168- '';
7171+ installTargets = "install" + optionalString withDoc " doc";
16972170170- meta = with stdenv.lib; {
7373+ meta = {
17174 homepage = "https://math-comp.github.io/";
17275 license = licenses.cecill-b;
173173- maintainers = [ maintainers.vbgl maintainers.jwiegley maintainers.cohencyril ];
174174- platforms = coq.meta.platforms;
175175- };
176176-177177- passthru = {
178178- mathcompDeps = mathcomp-deps package;
179179- inherit package mathcomp-config;
180180- compatibleCoqVersions = _: true;
181181- };
182182- };
183183-184184- # converts a string, path or attribute set into an override function
185185- toOverrideFun = overrides:
186186- if isFunction overrides then overrides else old:
187187- let
188188- pkgname = if old.passthru.package == "single" then "mathcomp"
189189- else "mathcomp-${old.passthru.package}";
190190-191191- string-attrs = if hasAttr overrides mathcomp-config.sha256 then
192192- let version = overrides;
193193- in {
194194- inherit version;
195195- src = fetchFromGitHub {
196196- owner = "math-comp";
197197- repo = "math-comp";
198198- rev = "mathcomp-${version}";
199199- sha256 = mathcomp-config.sha256.${version};
200200- };
201201- passthru = old.passthru // {
202202- compatibleCoqVersions = mathcomp-config.coq-versions.${version};
203203- mathcompDeps = mathcomp-config.deps version old.passthru.package;
204204- };
205205- }
206206- else
207207- let splitted = filter isString (split "/" overrides);
208208- owner = head splitted;
209209- ref = concatStringsSep "/" (tail splitted);
210210- version = head (reverseList splitted);
211211- in if length splitted == 1 then {
212212- inherit version;
213213- src = fetchTarball "https://github.com/math-comp/math-comp/archive/${version}.tar.gz";
214214- } else {
215215- inherit version;
216216- src = fetchTarball "https://github.com/${owner}/math-comp/archive/${ref}.tar.gz";
217217- };
218218-219219- attrs =
220220- if overrides == null || overrides == "" then _: {}
221221- else if isString overrides then string-attrs
222222- else if isPath overrides then { version = baseNameOf overrides; src = overrides; }
223223- else if isAttrs overrides then pkgUp old overrides
224224- else let overridesStr = toString overrides; in
225225- abort "${overridesStr} not a legitimate overrides";
226226- in
227227- attrs // (if attrs?version && ! (attrs?name)
228228- then { name = "coq${coq.coq-version}-${pkgname}-${attrs.version}"; } else {});
229229-230230- # generates {ssreflect = «derivation ...» ; ... ; character = «derivation ...», ...}
231231- mkMathcompGenSet = pkgs: o:
232232- fold (pkg: pkgs: pkgs // {${pkg} = mkMathcompGen pkg o;}) {} pkgs;
233233- # generates the derivation of one mathcomp package.
234234- mkMathcompGen = package: overrides:
235235- let
236236- up = x: o: x // (toOverrideFun o x);
237237- fixdeps = attrs:
238238- let version = attrs.version or "master";
239239- mcdeps = if package == "single" then {}
240240- else mkMathcompGenSet (filter isString attrs.passthru.mathcompDeps) overrides;
241241- allmc = mkMathcompGenSet (mathcomp-config.packages version ++ [ "single" ]) overrides;
242242- in {
243243- propagatedBuildInputs = [ coq ]
244244- ++ filter isDerivation attrs.passthru.mathcompDeps
245245- ++ attrValues mcdeps
246246- ;
247247- passthru = allmc //
248248- { overrideMathcomp = o: mathcomp_ (old: up (up old overrides) o); };
7676+ maintainers = with maintainers; [ vbgl jwiegley cohencyril ];
24977 };
250250- in
251251- stdenv.mkDerivation (up (up (default-attrs package) overrides) fixdeps);
7878+ } // optionalAttrs (package != "single") { passthru = genAttrs packages mathcomp_; });
7979+ patched-derivation1 = derivation.overrideAttrs (o:
8080+ optionalAttrs (o.pname != null && o.pname == "mathcomp-all" &&
8181+ o.version != null && o.version != "dev" && versions.isLt "1.7" o.version)
8282+ { preBuild = ""; buildPhase = ""; installPhase = "echo doing nothing"; }
8383+ );
8484+ patched-derivation = patched-derivation1.overrideAttrs (o:
8585+ optionalAttrs (versions.isLe "8.7" coq.coq-version ||
8686+ (o.version != "dev" && versions.isLe "1.7" o.version))
8787+ {
8888+ installFlags = o.installFlags ++ [ "-f Makefile.coq" ];
8989+ }
9090+ );
9191+ in patched-derivation;
25292in
253253-{
254254- mathcomp-config = mathcomp-config-initial;
255255- mathcomp_ = mkMathcompGen "all";
256256- mathcomp = mathcomp_ mathcomp-config.preferred-version;
257257- # mathcomp-single = mathcomp.single;
258258- ssreflect = mathcomp.ssreflect;
259259- mathcomp-ssreflect = mathcomp.ssreflect;
260260- mathcomp-fingroup = mathcomp.fingroup;
261261- mathcomp-algebra = mathcomp.algebra;
262262- mathcomp-solvable = mathcomp.solvable;
263263- mathcomp-field = mathcomp.field;
264264- mathcomp-character = mathcomp.character;
265265-}
9393+mathcomp_ (if single then "single" else "all")
-391
pkgs/development/coq-modules/mathcomp/extra.nix
···11-##########################################################
22-# Main derivation: #
33-# mathcomp-finmap mathcomp-analysis mathcomp-bigenough #
44-# mathcomp-multinomials mathcomp-real-closed coqeal #
55-# Additionally: #
66-# mathcomp-extra-all contains all the extra packages #
77-# mathcomp-extra-fast contains the one not marked slow #
88-########################################################################
99-# This file mainly provides the above derivations, which are packages #
1010-# extra mathcomp libraries based on mathcomp. #
1111-########################################################################
1212-1313-#####################################################
1414-# Compiling customs versions using `mathcomp-extra` #
1515-##############################################################################
1616-# The prefered way to compile a custom version of mathcomp extra packages #
1717-# (other than released versions which should be added to #
1818-# `rec-mathcomp-extra-config` and pushed to nixpkgs, see below), #
1919-# is to use `coqPackages.mathcomp-extra name version` where #
2020-# 1. `name` is a string representing the name of a declared package #
2121-# OR undeclared package. #
2222-# 2. `version` is either: #
2323-# - a string without slash, which is interpreted as a github revision, #
2424-# i.e. either a tag, a branch or a commit hash #
2525-# - a string with slashes "owner/p_1/.../p_n", which is interpreted as #
2626-# github owner "owner" and revision "p_1/.../p_n". #
2727-# - a path which is interpreted as a local source for the repository, #
2828-# the name of the version is taken to be the basename of the path #
2929-# i.e. if the path is /home/you/git/package/branch/, #
3030-# then "branch" is the name of the version #
3131-# - an attribute set which overrides some attributes (e.g. the src) #
3232-# if the version is updated, the name is automatically regenerated using #
3333-# the conventional schema "coq${coq.coq-version}-${pkgname}-${version}" #
3434-# - a "standard" override function (old: new_attrs) to override the default #
3535-# attribute set, so that you can use old.${field} to patch the derivation. #
3636-# #
3737-# Should you choose to use `pkg.overrideAttrs` instead, we provide the #
3838-# function mathcomp-extra-override which takes a name and a version exactly #
3939-# as above and returns an override function. #
4040-##############################################################################
4141-4242-#########################################################################
4343-# Example of use: https://github.com/math-comp/math-comp/wiki/Using-nix #
4444-#########################################################################
4545-4646-###########################################
4747-# Adding a new package or package version #
4848-################################################################################
4949-# 1. Update or add a `package` entry to `initial`, it must be a function #
5050-# taking the version as argument and returning an attribute set. Everything #
5151-# is optional and the default for the sources of the repository and the #
5252-# homepage will be https://github.com/math-comp/${package}. #
5353-# #
5454-# 2. Update or add a `package` entry to `sha256` for each release. #
5555-# You may use #
5656-# ```sh #
5757-# nix-prefetch-url --unpack #
5858-# https://github.com/math-comp/math-comp/archive/version.tar.gz #
5959-# ``` #
6060-# #
6161-# 3. Update or create a new consistent set of extra packages. #
6262-# /!\ They must all be co-compatible. /!\ #
6363-# Do not use versions that may disappear: it must either be #
6464-# - a tag from the main repository (e.g. version or tag), or #
6565-# - a revision hash that has been *merged in master* #
6666-################################################################################
6767-6868-{ stdenv, fetchFromGitHub, recurseIntoAttrs,
6969- which, mathcomp, coqPackages,
7070- mathcomp-extra-config, mathcomp-extra-override,
7171- mathcomp-extra, current-mathcomp-extra,
7272-}:
7373-with builtins // stdenv.lib;
7474-let
7575- ##############################
7676- # CONFIGURATION, please edit #
7777- ##############################
7878- ############################
7979- # Packages base delaration #
8080- ############################
8181- rec-mathcomp-extra-config = {
8282- initial = {
8383- mathcomp-finmap = {version, coqPackages}: {
8484- meta = {
8585- description = "A finset and finmap library";
8686- repo = "finmap";
8787- homepage = "https://github.com/math-comp/finmap";
8888- };
8989- passthru.compatibleCoqVersions = flip elem [ "8.8" "8.9" "8.10" "8.11" ];
9090- };
9191-9292- mathcomp-bigenough = {version, coqPackages}: {
9393- meta = {
9494- description = "A small library to do epsilon - N reasonning";
9595- repo = "bigenough";
9696- homepage = "https://github.com/math-comp/bigenough";
9797- };
9898- passthru.compatibleCoqVersions = flip elem [ "8.7" "8.8" "8.9" "8.10" "8.11" ];
9999- };
100100-101101- multinomials = {version, coqPackages}: {
102102- buildInputs = [ which ];
103103- propagatedBuildInputs = with coqPackages;
104104- [ mathcomp.algebra mathcomp-finmap mathcomp-bigenough ];
105105- meta = {
106106- description = "A Coq/SSReflect Library for Monoidal Rings and Multinomials";
107107- repo = "multinomials";
108108- homepage = "https://github.com/math-comp/multinomials";
109109- };
110110- passthru.compatibleCoqVersions = flip elem [ "8.9" "8.10" "8.11" ];
111111- };
112112-113113- mathcomp-analysis = {version, coqPackages}: {
114114- propagatedBuildInputs = with coqPackages;
115115- [ mathcomp.field mathcomp-finmap mathcomp-bigenough mathcomp-real-closed ];
116116- meta = {
117117- description = "Analysis library compatible with Mathematical Components";
118118- homepage = "https://github.com/math-comp/analysis";
119119- repo = "analysis";
120120- license = stdenv.lib.licenses.cecill-c;
121121- };
122122- passthru.compatibleCoqVersions = flip elem ["8.8" "8.9" "8.10" "8.11" ];
123123- };
124124-125125- mathcomp-real-closed = {version, coqPackages}: {
126126- propagatedBuildInputs = with coqPackages;
127127- [ mathcomp.field mathcomp-bigenough ];
128128- meta = {
129129- description = "Mathematical Components Library on real closed fields";
130130- repo = "real-closed";
131131- homepage = "https://github.com/math-comp/real-closed";
132132- };
133133- passthru.compatibleCoqVersions = flip elem ["8.8" "8.9" "8.10" "8.11" ];
134134- };
135135-136136- coqeal = {version, coqPackages}: {
137137- buildInputs = [ which ];
138138- propagatedBuildInputs = with coqPackages;
139139- [ mathcomp-algebra bignums paramcoq multinomials ];
140140- meta = {
141141- description = "CoqEAL - The Coq Effective Algebra Library";
142142- homepage = "https://github.com/coqeal/coqeal";
143143- license = stdenv.lib.licenses.mit;
144144- owner = "CoqEAL";
145145- };
146146- passthru.compatibleCoqVersions = flip elem [ "8.9" "8.10" "8.11" ];
147147- };
148148- };
149149-150150- ###############################
151151- # sha256 of released versions #
152152- ###############################
153153- sha256 = {
154154- mathcomp-finmap = {
155155- "1.5.0" = "0vx9n1fi23592b3hv5p5ycy7mxc8qh1y5q05aksfwbzkk5zjkwnq";
156156- "1.4.1" = "0kx4nx24dml1igk0w0qijmw221r5bgxhwhl5qicnxp7ab3c35s8p";
157157- "1.4.0+coq-8.11" = "1fd00ihyx0kzq5fblh9vr8s5mr1kg7p6pk11c4gr8svl1n69ppmb";
158158- "1.4.0" = "0mp82mcmrs424ff1vj3cvd8353r9vcap027h3p0iprr1vkkwjbzd";
159159- "1.3.4" = "0f5a62ljhixy5d7gsnwd66gf054l26k3m79fb8nz40i2mgp6l9ii";
160160- "1.3.3" = "1n844zjhv354kp4g4pfbajix0plqh7yxv6471sgyb46885298am5";
161161- "1.3.1" = "14rvm0rm5hd3pd0srgak3jqmddzfv6n7gdpjwhady5xcgrc7gsx7";
162162- "1.2.1" = "0jryb5dq8js3imbmwrxignlk5zh8gwfb1wr4b1s7jbwz410vp7zf";
163163- "1.2.0" = "0b6wrdr0d7rcnv86s37zm80540jl2wmiyf39ih7mw3dlwli2cyj4";
164164- "1.1.0" = "05df59v3na8jhpsfp7hq3niam6asgcaipg2wngnzxzqnl86srp2a";
165165- "1.0.0" = "0sah7k9qm8sw17cgd02f0x84hki8vj8kdz7h15i7rmz08rj0whpa";
166166- };
167167- mathcomp-bigenough = {
168168- "1.0.0" = "10g0gp3hk7wri7lijkrqna263346wwf6a3hbd4qr9gn8hmsx70wg";
169169- };
170170- mathcomp-analysis = {
171171- "0.3.1" = "1iad288yvrjv8ahl9v18vfblgqb1l5z6ax644w49w9hwxs93f2k8";
172172- "0.3.0" = "03klwi4fja0cqb4myp3kgycfbmdv00bznmxf8yg3zzzzw997hjqc";
173173- "0.2.3" = "0p9mr8g1qma6h10qf7014dv98ln90dfkwn76ynagpww7qap8s966";
174174- "0.2.2" = "1d5dwg9di2ppdzfg21zr0a691zigb5kz0lcw263jpyli1nrq7cvk";
175175- "0.2.0" = "1186xjxgns4ns1szyi931964bjm0mp126qzlv10mkqqgfw07nhrd";
176176- "0.1.0" = "0hwkr2wzy710pcyh274fcarzdx8sv8myp16pv0vq5978nmih46al";
177177- };
178178- multinomials = {
179179- "1.5.2" = "15aspf3jfykp1xgsxf8knqkxv8aav2p39c2fyirw7pwsfbsv2c4s";
180180- "1.5.1" = "13nlfm2wqripaq671gakz5mn4r0xwm0646araxv0nh455p9ndjs3";
181181- "1.5" = "064rvc0x5g7y1a0nip6ic91vzmq52alf6in2bc2dmss6dmzv90hw";
182182- "1.4" = "0vnkirs8iqsv8s59yx1fvg1nkwnzydl42z3scya1xp1b48qkgn0p";
183183- "1.3" = "0l3vi5n094nx3qmy66hsv867fnqm196r8v605kpk24gl0aa57wh4";
184184- "1.2" = "1mh1w339dslgv4f810xr1b8v2w7rpx6fgk9pz96q0fyq49fw2xcq";
185185- "1.1" = "1q8alsm89wkc0lhcvxlyn0pd8rbl2nnxg81zyrabpz610qqjqc3s";
186186- "1.0" = "1qmbxp1h81cy3imh627pznmng0kvv37k4hrwi2faa101s6bcx55m";
187187- };
188188- mathcomp-real-closed = {
189189- "1.1.1" = "0ksjscrgq1i79vys4zrmgvzy2y4ylxa8wdsf4kih63apw6v5ws6b";
190190- "1.1.0" = "0zgfmrlximw77bw5w6w0xg2nampp02pmrwnrzx8m1n5pqljnv8fh";
191191- "1.0.5" = "0q8nkxr9fba4naylr5xk7hfxsqzq2pvwlg1j0xxlhlgr3fmlavg2";
192192- "1.0.4" = "058v9dj973h9kfhqmvcy9a6xhhxzljr90cf99hdfcdx68fi2ha1b";
193193- "1.0.3" = "1xbzkzqgw5p42dx1liy6wy8lzdk39zwd6j14fwvv5735k660z7yb";
194194- "1.0.2" = "0097pafwlmzd0gyfs31bxpi1ih04i72nxhn99r93aj20mn7mcsgl";
195195- "1.0.1" = "0j81gkjbza5vg89v4n9z598mfdbql416963rj4b8fzm7dp2r4rxg";
196196- };
197197- coqeal = {
198198- "1.0.4" = "1g5m26lr2lwxh6ld2gykailhay4d0ayql4bfh0aiwqpmmczmxipk";
199199- "1.0.3" = "0hc63ny7phzbihy8l7wxjvn3haxx8jfnhi91iw8hkq8n29i23v24";
200200- "1.0.2" = "1brmf3gj03iky1bcl3g9vx8vknny7xfvs0y2rfr85am0296sxsfj";
201201- "1.0.1" = "19jhdrv2yp9ww0h8q73ihb2w1z3glz4waf2d2n45klafxckxi7bm";
202202- "1.0.0" = "1had6f1n85lmh9x31avbmgl3m0rsiw9f8ma95qzk5b57fjg5k1ii";
203203- };
204204- };
205205-206206- ################################
207207- # CONSISTENT sets of packages. #
208208- ################################
209209- for-coq-and-mc = let
210210- v6 = {
211211- mathcomp-finmap = "1.5.0";
212212- mathcomp-bigenough = "1.0.0";
213213- mathcomp-analysis = "0.3.1";
214214- multinomials = "1.5.2";
215215- mathcomp-real-closed = "1.1.1";
216216- coqeal = "1.0.4";
217217- };
218218- v5 = {
219219- mathcomp-finmap = "1.5.0";
220220- mathcomp-bigenough = "1.0.0";
221221- mathcomp-analysis = "0.3.0";
222222- multinomials = "1.5.1";
223223- mathcomp-real-closed = "1.0.5";
224224- coqeal = "1.0.4";
225225- };
226226- v4 = v3 // { coqeal = "1.0.3"; };
227227- v3 = {
228228- mathcomp-finmap = "1.4.0";
229229- mathcomp-bigenough = "1.0.0";
230230- mathcomp-analysis = "0.2.3";
231231- multinomials = "1.5";
232232- mathcomp-real-closed = "1.0.4";
233233- coqeal = "1.0.0";
234234- };
235235- v2 = {
236236- mathcomp-finmap = "1.3.4";
237237- mathcomp-bigenough = "1.0.0";
238238- mathcomp-analysis = "0.2.3";
239239- multinomials = "1.4";
240240- mathcomp-real-closed = "1.0.3";
241241- coqeal = "1.0.0";
242242- };
243243- v1 = {
244244- mathcomp-finmap = "1.1.0";
245245- mathcomp-bigenough = "1.0.0";
246246- multinomials = "1.1";
247247- mathcomp-real-closed = "1.0.1";
248248- coqeal = "1.0.0";
249249- };
250250- in
251251- {
252252- "8.11" = {
253253- "1.11.0" = v6;
254254- "1.11+beta1" = v5;
255255- "1.10.0" = v4 // {mathcomp-finmap = "1.4.0+coq-8.11";};
256256- };
257257- "8.10" = {
258258- "1.11.0" = removeAttrs v6 ["coqeal"];
259259- "1.11+beta1" = removeAttrs v5 ["coqeal"];
260260- "1.10.0" = v4;
261261- "1.9.0" = removeAttrs v3 ["coqeal"];
262262- };
263263- "8.9" = {
264264- "1.11.0" = removeAttrs v6 ["mathcomp-analysis"];
265265- "1.11+beta1" = removeAttrs v5 ["mathcomp-analysis"];
266266- "1.10.0" = v4;
267267- "1.9.0" = removeAttrs v3 ["coqeal"];
268268- "1.8.0" = removeAttrs v2 ["coqeal"];
269269- };
270270- "8.8" = {
271271- "1.11.0" = removeAttrs v6 ["mathcomp-analysis"];
272272- "1.11+beta1" = removeAttrs v5 ["mathcomp-analysis"];
273273- "1.10.0" = removeAttrs v4 ["mathcomp-analysis"];
274274- "1.9.0" = removeAttrs v3 ["coqeal"];
275275- "1.8.0" = removeAttrs v2 ["coqeal"];
276276- "1.7.0" = removeAttrs v1 ["coqeal" "multinomials"];
277277- };
278278- "8.7" = {
279279- "1.11.0" = removeAttrs v6 ["mathcomp-analysis"];
280280- "1.11+beta1" = removeAttrs v5 ["mathcomp-analysis"];
281281- "1.10.0" = removeAttrs v4 ["mathcomp-analysis"];
282282- "1.9.0" = removeAttrs v3 ["coqeal" "mathcomp-analysis"];
283283- "1.8.0" = removeAttrs v2 ["coqeal" "mathcomp-analysis"];
284284- "1.7.0" = removeAttrs v1 ["coqeal" "multinomials"];
285285- };
286286- };
287287- };
288288-289289- ##############################
290290- # GENERATION, EDIT WITH CARE #
291291- ##############################
292292- coq = coqPackages.coq;
293293-294294- default-attrs = {
295295- version = "master";
296296- buildInputs = [];
297297- propagatedBuildInputs = (with coqPackages; [ ssreflect ]);
298298- installFlags = [ "-f" "Makefile.coq" "COQLIB=$(out)/lib/coq/${coq.coq-version}/" ];
299299- meta = {
300300- inherit (mathcomp.meta) platforms license;
301301- owner = "math-comp";
302302- maintainers = [ maintainers.vbgl maintainers.cohencyril ];
303303- };
304304- passthru.compatibleCoqVersions = (_: true);
305305- };
306306-307307- pkgUp = recursiveUpdateUntil (path: l: r: !(isAttrs l && isAttrs r) || path == ["src"]);
308308-309309- # Fixes a partial attribute set using the configuration
310310- # in the style of the above mathcomp-extra-config.initial,
311311- # and generates a name according to the conventional naming scheme below
312312- fix-attrs = pkgcfg:
313313- let attrs = pkgUp default-attrs pkgcfg; in
314314- pkgUp attrs (rec {
315315- name = "coq${coq.coq-version}mathcomp${mathcomp.version}-${attrs.meta.repo or attrs.meta.package or "anonymous"}-${attrs.version}";
316316- src = attrs.src or (fetchTarball "${meta.homepage}/archive/${attrs.version}.tar.gz");
317317- meta = rec {
318318- homepage = attrs.meta.homepage or attrs.src.meta.homepage or "https://github.com/${owner}/${repo}";
319319- owner = attrs.meta.owner or "math-comp";
320320- repo = attrs.meta.repo or attrs.meta.package or "math-comp-nix";
321321- };
322322- });
323323-324324- # Gets a version out of a string, path or attribute set.
325325- getVersion = arg:
326326- if isFunction arg then (arg {}).version
327327- else if arg == "" then "master"
328328- else if isDerivation arg then arg.drvAttrs.version or "master"
329329- else if isAttrs arg then arg.version or "master"
330330- else if isString arg then head (reverseList (split "/" arg))
331331- else if isPath arg then (baseNameOf arg)
332332- else "master";
333333-334334- # Converts a string, path or attribute set into an override function
335335- # It tries to fill the `old` argument of the override function using
336336- # `mathcomp-extra-config.initial` first and finishes with `fix-attrs`
337337- rec-mathcomp-extra-override = generic: old: let
338338- version = getVersion generic;
339339- package = old.meta.package or "math-comp-nix";
340340- cfg = pkgUp ((mathcomp-extra-config.initial.${package} or (_: {}))
341341- { inherit version coqPackages; }) old
342342- // { inherit version; };
343343- fix = attrs: fix-attrs (pkgUp cfg attrs);
344344- in
345345- if isFunction generic then fix (generic cfg)
346346- else if generic == null || generic == "" then fix {}
347347- else if isDerivation generic then generic.drvAttrs
348348- else if isAttrs generic then fix generic
349349- else if generic == "broken" then fix { meta.broken = true; passthru.compatibleCoqVersions = _: false; }
350350- else let fixedcfg = fix cfg; in fixedcfg // (
351351- if isString generic then
352352- if (mathcomp-extra-config.sha256.${package} or {})?${generic} then {
353353- src = fetchFromGitHub {
354354- inherit (fixedcfg.meta) owner repo;
355355- rev = version;
356356- sha256 = mathcomp-extra-config.sha256.${package}.${version};
357357- };
358358- }
359359- else let splitted = filter isString (split "/" generic); in {
360360- src = fetchTarball
361361- ("https://github.com/" +
362362- (if length splitted == 1 then "${fixedcfg.meta.owner}/${fixedcfg.meta.repo}/archive/${version}.tar.gz"
363363- else "${head splitted}/${fixedcfg.meta.repo}/archive/${concatStringsSep "/" (tail splitted)}.tar.gz"));
364364- }
365365- else if isPath generic then { src = generic; }
366366- else abort "${toString generic} not a legitimate generic version/override");
367367-368368- # applies mathcomp-extra-config.for-coq-and-mc to the current mathcomp version
369369- for-this = mathcomp-extra-config.for-coq-and-mc.${coq.coq-version}.${mathcomp.version} or {};
370370-371371- # specializes mathcomp-extra to the current mathcomp version.
372372- rec-current-mathcomp-extra = package: mathcomp-extra package (for-this.${package} or {});
373373-in
374374- {
375375- mathcomp-extra-override = rec-mathcomp-extra-override;
376376- mathcomp-extra-config = rec-mathcomp-extra-config;
377377- current-mathcomp-extra = rec-current-mathcomp-extra;
378378- mathcomp-extra = package: version:
379379- stdenv.mkDerivation (mathcomp-extra-override version {meta = {inherit package;};});
380380-381381- mathcomp-finmap = current-mathcomp-extra "mathcomp-finmap";
382382- mathcomp-analysis = current-mathcomp-extra "mathcomp-analysis";
383383- mathcomp-bigenough = current-mathcomp-extra "mathcomp-bigenough";
384384- multinomials = current-mathcomp-extra "multinomials";
385385- mathcomp-real-closed = current-mathcomp-extra "mathcomp-real-closed";
386386- coqeal = current-mathcomp-extra "coqeal";
387387-388388- mathcomp-extra-fast = map current-mathcomp-extra
389389- (attrNames (filterAttrs (pkg: config: !(config?slow && config.slow)) for-this));
390390- mathcomp-extra-all = map current-mathcomp-extra (attrNames for-this);
391391- }
···11-{ stdenv, lib, fetchFromGitHub, pkg-config, cmake, git, doxygen, help2man, ncurses, tecla
11+{ stdenv, lib, fetchFromGitHub, fetchpatch, pkg-config, cmake, git, doxygen, help2man, ncurses, tecla
22, libusb1, udev }:
3344let
···2222 rev = "libbladeRF_v${version}";
2323 sha256 = "0g89al4kwfbx1l3zjddgb9ay4mhr7zk0ndchca3sm1vq2j47nf4l";
2424 };
2525+2626+ # This patch is required for version 2.2.1. As the patch is already part of
2727+ # upstream master, it will be incorporated into the next release. The patch
2828+ # fixes a (well-justified) compiler warning which breaks the build because
2929+ # we compile with -Werror.
3030+ patches = [ (fetchpatch {
3131+ url = "https://github.com/Nuand/bladeRF/commit/163425d48a3b7d8c100d7295220d3648c050d0dd.patch";
3232+ sha256 = "1swsymlyxm3yk2k8l71z1fv0a5k2rmab02f0c7xkrvk683mq6yxw";
3333+ }) ];
25342635 nativeBuildInputs = [ cmake pkg-config git doxygen help2man ];
2736 # ncurses used due to https://github.com/Nuand/bladeRF/blob/ab4fc672c8bab4f8be34e8917d3f241b1d52d0b8/host/utilities/bladeRF-cli/CMakeLists.txt#L208