···1-# Coq {#sec-language-coq}
23-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.
45-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.
000000000000000000000000000000067-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.
89-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.
1011```nix
12-{ stdenv, fetchFromGitHub, coq, mathcomp }:
13-14-stdenv.mkDerivation rec {
15- name = "coq${coq.coq-version}-multinomials-${version}";
16- version = "1.0";
17- src = fetchFromGitHub {
18- owner = "math-comp";
19- repo = "multinomials";
20- rev = version;
21- sha256 = "1qmbxp1h81cy3imh627pznmng0kvv37k4hrwi2faa101s6bcx55m";
0000000000000022 };
2324- buildInputs = [ coq ];
25- propagatedBuildInputs = [ mathcomp ];
26-27- installFlags = "COQLIB=$(out)/lib/coq/${coq.coq-version}/";
2829 meta = {
30 description = "A Coq/SSReflect Library for Monoidal Rings and Multinomials";
31- inherit (src.meta) homepage;
32- license = stdenv.lib.licenses.cecill-b;
33- inherit (coq.meta) platforms;
34- };
35-36- passthru = {
37- compatibleCoqVersions = v: builtins.elem v [ "8.5" "8.6" "8.7" ];
38 };
39}
40```
···1+# Coq and coq packages {#sec-language-coq}
23+## Coq derivation: `coq`
45+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
6++ `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,
7++ `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).
8++ `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"; }`.
9+10+## Coq packages attribute sets: `coqPackages`
11+12+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:
13+- `pname` (required) is the name of the package,
14+- `version` (optional, defaults to `null`), is the version to fetch and build,
15+ this attribute is interpreted in several ways depending on its type and pattern:
16+ + 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,
17+ + 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`),
18+ + 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"`,
19+ + 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),
20+ + 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,
21+- `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.
22+- `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`).
23+- `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`.
24+- `repo` (optional, defaults to the value of `pname`),
25+- `owner` (optional, defaults to `"coq-community"`).
26+- `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),
27+- `releaseRev` (optional, defaults to `(v: v)`), provides a default mapping from release names to revision hashes/branch names/tags,
28+- `displayVersion` (optional), provides a way to alter the computation of `name` from `pname`, by explaining how to display version numbers,
29+- `namePrefix` (optional), provides a way to alter the computation of `name` from `pname`, by explaining which dependencies must occur in `name`,
30+- `extraBuildInputs` (optional), by default `buildInputs` just contains `coq`, this allows to add more build inputs,
31+- `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.
32+- `enableParallelBuilding` (optional, defaults to `true`), since it is activated by default, we provide a way to disable it.
33+- `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.
34+- `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`,
35+- `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).
36+- `dropAttrs`, `keepAttrs`, `dropDerivationAttrs` are all optional and allow to tune which attribute is added or removed from the final call to `mkDerivation`.
3738+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).
3940+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`.
4142```nix
43+{ coq, mkCoqDerivation, mathcomp, mathcomp-finmap, mathcomp-bigenough,
44+ lib, version ? null }:
45+with lib; mkCoqDerivation {
46+ /* namePrefix leads to e.g. `name = coq8.11-mathcomp1.11-multinomials-1.5.2` */
47+ namePrefix = [ "coq" "mathcomp" ];
48+ pname = "multinomials";
49+ owner = "math-comp";
50+ inherit version;
51+ defaultVersion = with versions; switch [ coq.version mathcomp.version ] [
52+ { cases = [ (range "8.7" "8.12") "1.11.0" ]; out = "1.5.2"; }
53+ { cases = [ (range "8.7" "8.11") (range "1.8" "1.10") ]; out = "1.5.0"; }
54+ { cases = [ (range "8.7" "8.10") (range "1.8" "1.10") ]; out = "1.4"; }
55+ { cases = [ "8.6" (range "1.6" "1.7") ]; out = "1.1"; }
56+ ] null;
57+ release = {
58+ "1.5.2".sha256 = "15aspf3jfykp1xgsxf8knqkxv8aav2p39c2fyirw7pwsfbsv2c4s";
59+ "1.5.1".sha256 = "13nlfm2wqripaq671gakz5mn4r0xwm0646araxv0nh455p9ndjs3";
60+ "1.5.0".sha256 = "064rvc0x5g7y1a0nip6ic91vzmq52alf6in2bc2dmss6dmzv90hw";
61+ "1.5.0".rev = "1.5";
62+ "1.4".sha256 = "0vnkirs8iqsv8s59yx1fvg1nkwnzydl42z3scya1xp1b48qkgn0p";
63+ "1.3".sha256 = "0l3vi5n094nx3qmy66hsv867fnqm196r8v605kpk24gl0aa57wh4";
64+ "1.2".sha256 = "1mh1w339dslgv4f810xr1b8v2w7rpx6fgk9pz96q0fyq49fw2xcq";
65+ "1.1".sha256 = "1q8alsm89wkc0lhcvxlyn0pd8rbl2nnxg81zyrabpz610qqjqc3s";
66+ "1.0".sha256 = "1qmbxp1h81cy3imh627pznmng0kvv37k4hrwi2faa101s6bcx55m";
67 };
6869+ propagatedBuildInputs =
70+ [ mathcomp.ssreflect mathcomp.algebra mathcomp-finmap mathcomp-bigenough ];
007172 meta = {
73 description = "A Coq/SSReflect Library for Monoidal Rings and Multinomials";
74+ license = licenses.cecill-c;
00000075 };
76}
77```
···1+{ lib }:
2+with builtins; with lib; recursiveUpdate lib (rec {
3+4+ versions =
5+ let
6+ truncate = n: v: concatStringsSep "." (take n (splitVersion v));
7+ opTruncate = op: v0: v: let n = length (splitVersion v0); in
8+ op (truncate n v) (truncate n v0);
9+ in rec {
10+11+ /* Get string of the first n parts of a version string.
12+13+ Example:
14+ - truncate 2 "1.2.3-stuff"
15+ => "1.2"
16+17+ - truncate 4 "1.2.3-stuff"
18+ => "1.2.3.stuff"
19+ */
20+21+ inherit truncate;
22+23+ /* Get string of the first three parts (major, minor and patch)
24+ of a version string.
25+26+ Example:
27+ majorMinorPatch "1.2.3-stuff"
28+ => "1.2.3"
29+ */
30+ majorMinorPatch = truncate 3;
31+32+ /* Version comparison predicates,
33+ - isGe v0 v <-> v is greater or equal than v0 [*]
34+ - isLe v0 v <-> v is lesser or equal than v0 [*]
35+ - isGt v0 v <-> v is strictly greater than v0 [*]
36+ - isLt v0 v <-> v is strictly lesser than v0 [*]
37+ - isEq v0 v <-> v is equal to v0 [*]
38+ - range low high v <-> v is between low and high [**]
39+40+ [*] truncating v to the same number of digits as v0
41+ [**] truncating v to low for the lower bound and high for the upper bound
42+43+ Examples:
44+ - isGe "8.10" "8.10.1"
45+ => true
46+ - isLe "8.10" "8.10.1"
47+ => true
48+ - isGt "8.10" "8.10.1"
49+ => false
50+ - isGt "8.10.0" "8.10.1"
51+ => true
52+ - isEq "8.10" "8.10.1"
53+ => true
54+ - range "8.10" "8.11" "8.11.1"
55+ => true
56+ - range "8.10" "8.11+" "8.11.0"
57+ => false
58+ - range "8.10" "8.11+" "8.11+beta1"
59+ => false
60+61+ */
62+ isGe = opTruncate versionAtLeast;
63+ isGt = opTruncate (flip versionOlder);
64+ isLe = opTruncate (flip versionAtLeast);
65+ isLt = opTruncate versionOlder;
66+ isEq = opTruncate pred.equal;
67+ range = low: high: pred.inter (versions.isGe low) (versions.isLe high);
68+ };
69+70+ /* Returns a list of list, splitting it using a predicate.
71+ This is analoguous to builtins.split sep list,
72+ with a predicate as a separator and a list instead of a string.
73+74+ Type: splitList :: (a -> bool) -> [a] -> [[a]]
75+76+ Example:
77+ splitList (x: x == "x") [ "y" "x" "z" "t" ]
78+ => [ [ "y" ] "x" [ "z" "t" ] ]
79+ */
80+ splitList = pred: l: # put in file lists
81+ let loop = (vv: v: l: if l == [] then vv ++ [v]
82+ else let hd = head l; tl = tail l; in
83+ if pred hd then loop (vv ++ [ v hd ]) [] tl else loop vv (v ++ [hd]) tl);
84+ in loop [] [] l;
85+86+ pred = {
87+ /* Predicate intersection, union, and complement */
88+ inter = p: q: x: p x && q x;
89+ union = p: q: x: p x || q x;
90+ compl = p: x: ! p x;
91+ true = p: true;
92+ false = p: false;
93+94+ /* predicate "being equal to y" */
95+ equal = y: x: x == y;
96+ };
97+98+ /* Emulate a "switch - case" construct,
99+ instead of relying on `if then else if ...` */
100+ /* Usage:
101+ ```nix
102+ switch-if [
103+ if-clause-1
104+ ..
105+ if-clause-k
106+ ] default-out
107+ ```
108+ where a if-clause has the form `{ cond = b; out = r; }`
109+ the first branch such as `b` is true */
110+111+ switch-if = c: d: (findFirst (getAttr "cond") {} c).out or d;
112+113+ /* Usage:
114+ ```nix
115+ switch x [
116+ simple-clause-1
117+ ..
118+ simple-clause-k
119+ ] default-out
120+ ```
121+ where a simple-clause has the form `{ case = p; out = r; }`
122+ the first branch such as `p x` is true
123+ or
124+ ```nix
125+ switch [ x1 .. xn ] [
126+ complex-clause-1
127+ ..
128+ complex-clause-k
129+ ] default-out
130+ ```
131+ where a complex-clause is either a simple-clause
132+ or has the form { cases = [ p1 .. pn ]; out = r; }
133+ in which case the first branch such as all `pi x` are true
134+135+ if the variables p are not functions,
136+ they are converted to a equal p
137+ if out is missing the default-out is taken */
138+139+ switch = var: clauses: default: with pred; let
140+ compare = f: if isFunction f then f else equal f;
141+ combine = cl: var:
142+ if cl?case then compare cl.case var
143+ else all (equal true) (zipListsWith compare cl.cases var); in
144+ switch-if (map (cl: { cond = combine cl var; inherit (cl) out; }) clauses) default;
145+})
···1-#############################
2-# Main derivation: mathcomp #
3-########################################################################
4-# This file mainly provides the `mathcomp` derivation, which is #
5-# essentially a meta-package containing all core mathcomp libraries #
6-# (ssreflect fingroup algebra solvable field character). They can be #
7-# accessed individually through the paththrough attributes of mathcomp #
8-# bearing the same names (mathcomp.ssreflect, etc). #
9-# #
10-# Do not use overrideAttrs, but overrideMathcomp instead, which #
11-# regenerate a full mathcomp derivation with sub-derivations, and #
12-# behave the same as `mathcomp_`, described below. #
13-########################################################################
1415-############################################################
16-# Compiling a custom version of mathcomp using `mathcomp_` #
17-##############################################################################
18-# The prefered way to compile a custom version of mathcomp (other than a #
19-# released version which should be added to `mathcomp-config-initial` #
20-# and pushed to nixpkgs), is to apply the function `coqPackages.mathcomp_` #
21-# to either: #
22-# - a string without slash, which is interpreted as a github revision, #
23-# i.e. either a tag, a branch or a commit hash #
24-# - a string with slashes "owner/p_1/.../p_n", which is interpreted as #
25-# github owner "owner" and revision "p_1/.../p_n". #
26-# - a path which is interpreted as a local source for the repository, #
27-# the name of the version is taken to be the basename of the path #
28-# i.e. if the path is /home/you/git/package/branch/, #
29-# then "branch" is the name of the version #
30-# - an attribute set which overrides some attributes (e.g. the src) #
31-# if the version is updated, the name is automatically regenerated using #
32-# the conventional schema "coq${coq.coq-version}-${pkgname}-${version}" #
33-# - a "standard" override function (old: new_attrs) to override the default #
34-# attribute set, so that you can use old.${field} to patch the derivation. #
35-##############################################################################
36-37-#########################################################################
38-# Example of use: https://github.com/math-comp/math-comp/wiki/Using-nix #
39-#########################################################################
40-41-#################################
42-# Adding a new mathcomp version #
43-#############################################################################
44-# When adding a new version of mathcomp, add an attribute to `sha256` (use #
45-# ```sh #
46-# nix-prefetch-url --unpack #
47-# https://github.com/math-comp/math-comp/archive/version.tar.gz #
48-# ``` #
49-# to get the corresponding `sha256`) and to `coq-version` (read the release #
50-# notes to check which versions of coq it is compatible with). Then add #
51-# it in `preference version`, if not all mathcomp-extra packages are #
52-# ready, you might want to give new release secondary priority. #
53-#############################################################################
54-55-56-{ stdenv, fetchFromGitHub, ncurses, which, graphviz,
57- recurseIntoAttrs, withDoc ? false,
58- coqPackages,
59- mathcomp_, mathcomp, mathcomp-config,
60-}:
61-with builtins // stdenv.lib;
62let
63- mathcomp-config-initial = rec {
64- #######################################################################
65- # CONFIGURATION (please edit this), it is exported as mathcomp-config #
66- #######################################################################
67- # sha256 of released mathcomp versions
68- sha256 = {
69- "1.12.0" = "1ccfny1vwgmdl91kz5xlmhq4wz078xm4z5wpd0jy5rn890dx03wp";
70- "1.11.0" = "06a71d196wd5k4wg7khwqb7j7ifr7garhwkd54s86i0j7d6nhl3c";
71- "1.11+beta1" = "12i3zznwajlihzpqsiqniv20rklj8d8401lhd241xy4s21fxkkjm";
72- "1.10.0" = "1b9m6pwxxyivw7rgx82gn5kmgv2mfv3h3y0mmjcjfypi8ydkrlbv";
73- "1.9.0" = "0lid9zaazdi3d38l8042lczb02pw5m9wq0yysiilx891hgq2p81r";
74- "1.8.0" = "07l40is389ih8bi525gpqs3qp4yb2kl11r9c8ynk1ifpjzpnabwp";
75- "1.7.0" = "0wnhj9nqpx2bw6n1l4i8jgrw3pjajvckvj3lr4vzjb3my2lbxdd1";
76- "1.6.1" = "1ilw6vm4dlsdv9cd7kmf0vfrh2kkzr45wrqr8m37miy0byzr4p9i";
77- };
78- # versions of coq compatible with released mathcomp versions
79- coq-versions = {
80- "1.12.0" = flip elem [ "8.13" ];
81- "1.11.0" = flip elem [ "8.7" "8.8" "8.9" "8.10" "8.11" "8.12" ];
82- "1.11+beta1" = flip elem [ "8.7" "8.8" "8.9" "8.10" "8.11" "8.12" ];
83- "1.10.0" = flip elem [ "8.7" "8.8" "8.9" "8.10" "8.11" ];
84- "1.9.0" = flip elem [ "8.7" "8.8" "8.9" "8.10" ];
85- "1.8.0" = flip elem [ "8.7" "8.8" "8.9" ];
86- "1.7.0" = flip elem [ "8.6" "8.7" "8.8" "8.9" ];
87- "1.6.1" = flip elem [ "8.5"];
88- };
89-90- # sets the default version of mathcomp given a version of Coq
91- # this is currently computed using version-perference below
92- # but it can be set to a fixed version number
93- preferred-version = let v = head (
94- filter (mc: mathcomp-config.coq-versions.${mc} coq.coq-version)
95- mathcomp-config.version-preferences ++ ["0.0.0"]);
96- in if v == "0.0.0" then head mathcomp-config.version-preferences else v;
97-98- # mathcomp preferred versions by decreasing order
99- # (the first version in the list will be tried first)
100- version-preferences =
101- [ "1.12.0" "1.10.0" "1.11.0" "1.9.0" "1.8.0" "1.7.0" "1.6.1" ];
102-103- # list of core mathcomp packages sorted by dependency order
104- packages = _version: # unused in current versions of mathcomp
105- # because the following list of packages is fixed for
106- # all versions of mathcomp up to 1.11.0
107- [ "ssreflect" "fingroup" "algebra" "solvable" "field" "character" "all" ];
108-109- # compute the dependencies of the core package pkg
110- # (assuming the total ordering above, change if necessary)
111- deps = version: pkg: if pkg == "single" then [] else
112- (pred-split-list (x: x == pkg) (mathcomp-config.packages version)).left;
113- };
114-115- ##############################################################
116- # COMPUTED using the configuration above (edit with caution) #
117- ##############################################################
118-119- # generic split function (TODO: move to lib?)
120- pred-split-list = pred: l:
121- let loop = v: l: if l == [] then {left = v; right = [];}
122- else let hd = builtins.head l; tl = builtins.tail l; in
123- if pred hd then {left = v; right = tl;} else loop (v ++ [hd]) tl;
124- in loop [] l;
125-126- pkgUp = l: r: l // r // {
127- meta = (l.meta or {}) // (r.meta or {});
128- passthru = (l.passthru or {}) // (r.passthru or {});
129 };
0130131- coq = coqPackages.coq;
132- mathcomp-deps = mathcomp-config.deps mathcomp.config.preferred-version;
133134- # default set of attributes given a 'package' name.
135- # this attribute set will be extended using toOverrideFun
136- default-attrs = package:
137- let
138 pkgpath = if package == "single" then "mathcomp" else "mathcomp/${package}";
139- pkgname = if package == "single" then "mathcomp" else "mathcomp-${package}";
140 pkgallMake = ''
141 echo "all.v" > Make
142 echo "-I ." >> Make
143 echo "-R . mathcomp.all" >> Make
144 '';
145- in
146- rec {
147- version = "master";
148- name = "coq${coq.coq-version}-${pkgname}-${version}";
149150- nativeBuildInputs = optionals withDoc [ graphviz ];
151- buildInputs = [ ncurses which ] ++ (with coq.ocamlPackages; [ ocaml findlib camlp5 ]);
152- propagatedBuildInputs = [ coq ];
153- enableParallelBuilding = true;
154155 buildFlags = optional withDoc "doc";
156157- COQBIN = "${coq}/bin/";
158-159 preBuild = ''
160 patchShebangs etc/utils/ssrcoqdep || true
0161 cd ${pkgpath}
162 '' + optionalString (package == "all") pkgallMake;
163164- installPhase = ''
165- make -f Makefile.coq COQLIB=$out/lib/coq/${coq.coq-version}/ install
166- '' + optionalString withDoc ''
167- make -f Makefile.coq install-doc DOCDIR=$out/share/coq/${coq.coq-version}/
168- '';
169170- meta = with stdenv.lib; {
171 homepage = "https://math-comp.github.io/";
172 license = licenses.cecill-b;
173- maintainers = [ maintainers.vbgl maintainers.jwiegley maintainers.cohencyril ];
174- platforms = coq.meta.platforms;
175- };
176-177- passthru = {
178- mathcompDeps = mathcomp-deps package;
179- inherit package mathcomp-config;
180- compatibleCoqVersions = _: true;
181- };
182- };
183-184- # converts a string, path or attribute set into an override function
185- toOverrideFun = overrides:
186- if isFunction overrides then overrides else old:
187- let
188- pkgname = if old.passthru.package == "single" then "mathcomp"
189- else "mathcomp-${old.passthru.package}";
190-191- string-attrs = if hasAttr overrides mathcomp-config.sha256 then
192- let version = overrides;
193- in {
194- inherit version;
195- src = fetchFromGitHub {
196- owner = "math-comp";
197- repo = "math-comp";
198- rev = "mathcomp-${version}";
199- sha256 = mathcomp-config.sha256.${version};
200- };
201- passthru = old.passthru // {
202- compatibleCoqVersions = mathcomp-config.coq-versions.${version};
203- mathcompDeps = mathcomp-config.deps version old.passthru.package;
204- };
205- }
206- else
207- let splitted = filter isString (split "/" overrides);
208- owner = head splitted;
209- ref = concatStringsSep "/" (tail splitted);
210- version = head (reverseList splitted);
211- in if length splitted == 1 then {
212- inherit version;
213- src = fetchTarball "https://github.com/math-comp/math-comp/archive/${version}.tar.gz";
214- } else {
215- inherit version;
216- src = fetchTarball "https://github.com/${owner}/math-comp/archive/${ref}.tar.gz";
217- };
218-219- attrs =
220- if overrides == null || overrides == "" then _: {}
221- else if isString overrides then string-attrs
222- else if isPath overrides then { version = baseNameOf overrides; src = overrides; }
223- else if isAttrs overrides then pkgUp old overrides
224- else let overridesStr = toString overrides; in
225- abort "${overridesStr} not a legitimate overrides";
226- in
227- attrs // (if attrs?version && ! (attrs?name)
228- then { name = "coq${coq.coq-version}-${pkgname}-${attrs.version}"; } else {});
229-230- # generates {ssreflect = «derivation ...» ; ... ; character = «derivation ...», ...}
231- mkMathcompGenSet = pkgs: o:
232- fold (pkg: pkgs: pkgs // {${pkg} = mkMathcompGen pkg o;}) {} pkgs;
233- # generates the derivation of one mathcomp package.
234- mkMathcompGen = package: overrides:
235- let
236- up = x: o: x // (toOverrideFun o x);
237- fixdeps = attrs:
238- let version = attrs.version or "master";
239- mcdeps = if package == "single" then {}
240- else mkMathcompGenSet (filter isString attrs.passthru.mathcompDeps) overrides;
241- allmc = mkMathcompGenSet (mathcomp-config.packages version ++ [ "single" ]) overrides;
242- in {
243- propagatedBuildInputs = [ coq ]
244- ++ filter isDerivation attrs.passthru.mathcompDeps
245- ++ attrValues mcdeps
246- ;
247- passthru = allmc //
248- { overrideMathcomp = o: mathcomp_ (old: up (up old overrides) o); };
249 };
250- in
251- stdenv.mkDerivation (up (up (default-attrs package) overrides) fixdeps);
000000000000252in
253-{
254- mathcomp-config = mathcomp-config-initial;
255- mathcomp_ = mkMathcompGen "all";
256- mathcomp = mathcomp_ mathcomp-config.preferred-version;
257- # mathcomp-single = mathcomp.single;
258- ssreflect = mathcomp.ssreflect;
259- mathcomp-ssreflect = mathcomp.ssreflect;
260- mathcomp-fingroup = mathcomp.fingroup;
261- mathcomp-algebra = mathcomp.algebra;
262- mathcomp-solvable = mathcomp.solvable;
263- mathcomp-field = mathcomp.field;
264- mathcomp-character = mathcomp.character;
265-}
···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+############################################################################
001213+{ lib, ncurses, which, graphviz, lua,
14+ mkCoqDerivation, recurseIntoAttrs, withDoc ? false, single ? false,
15+ coqPackages, coq, ocamlPackages, version ? null }@args:
16+with builtins // lib;
000000000000000000000000000000000000000000017let
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.13"; out = "1.12.0"; } # lower version of coq to 8.10 when all mathcomp packages are ported
23+ { case = range "8.7" "8.12"; out = "1.11.0"; }
24+ { case = range "8.7" "8.11"; out = "1.10.0"; }
25+ { case = range "8.7" "8.11"; out = "1.9.0"; }
26+ { case = range "8.7" "8.9"; out = "1.8.0"; }
27+ { case = range "8.6" "8.9"; out = "1.7.0"; }
28+ { case = range "8.5" "8.7"; out = "1.6.4"; }
29+ ] null;
30+ release = {
31+ "1.12.0".sha256 = "1ccfny1vwgmdl91kz5xlmhq4wz078xm4z5wpd0jy5rn890dx03wp";
32+ "1.11.0".sha256 = "06a71d196wd5k4wg7khwqb7j7ifr7garhwkd54s86i0j7d6nhl3c";
33+ "1.10.0".sha256 = "1b9m6pwxxyivw7rgx82gn5kmgv2mfv3h3y0mmjcjfypi8ydkrlbv";
34+ "1.9.0".sha256 = "0lid9zaazdi3d38l8042lczb02pw5m9wq0yysiilx891hgq2p81r";
35+ "1.8.0".sha256 = "07l40is389ih8bi525gpqs3qp4yb2kl11r9c8ynk1ifpjzpnabwp";
36+ "1.7.0".sha256 = "0wnhj9nqpx2bw6n1l4i8jgrw3pjajvckvj3lr4vzjb3my2lbxdd1";
37+ "1.6.4".sha256 = "09ww48qbjsvpjmy1g9yhm0rrkq800ffq21p6fjkbwd34qvd82raz";
38+ "1.6.1".sha256 = "1ilw6vm4dlsdv9cd7kmf0vfrh2kkzr45wrqr8m37miy0byzr4p9i";
00000000000000000000000000000000000000000000039 };
40+ releaseRev = v: "mathcomp-${v}";
4142+ # list of core mathcomp packages sorted by dependency order
43+ packages = [ "ssreflect" "fingroup" "algebra" "solvable" "field" "character" "all" ];
4445+ mathcomp_ = package: let
46+ mathcomp-deps = if package == "single" then []
47+ else map mathcomp_ (head (splitList (pred.equal package) packages));
048 pkgpath = if package == "single" then "mathcomp" else "mathcomp/${package}";
49+ pname = if package == "single" then "mathcomp" else "mathcomp-${package}";
50 pkgallMake = ''
51 echo "all.v" > Make
52 echo "-I ." >> Make
53 echo "-R . mathcomp.all" >> Make
54 '';
55+ derivation = mkCoqDerivation ({
56+ inherit version pname defaultVersion release releaseRev repo owner;
005758+ nativeBuildInputs = optional withDoc graphviz;
59+ mlPlugin = versions.isLe "8.6" coq.coq-version;
60+ extraBuildInputs = [ ncurses which ] ++ optional withDoc lua;
61+ propagatedBuildInputs = mathcomp-deps;
6263 buildFlags = optional withDoc "doc";
640065 preBuild = ''
66 patchShebangs etc/utils/ssrcoqdep || true
67+ '' + ''
68 cd ${pkgpath}
69 '' + optionalString (package == "all") pkgallMake;
7071+ installTargets = "install" + optionalString withDoc " doc";
00007273+ meta = {
74 homepage = "https://math-comp.github.io/";
75 license = licenses.cecill-b;
76+ maintainers = with maintainers; [ vbgl jwiegley cohencyril ];
00000000000000000000000000000000000000000000000000000000000000000000000000077 };
78+ } // optionalAttrs (package != "single") { passthru = genAttrs packages mathcomp_; });
79+ patched-derivation1 = derivation.overrideAttrs (o:
80+ optionalAttrs (o.pname != null && o.pname == "mathcomp-all" &&
81+ o.version != null && o.version != "dev" && versions.isLt "1.7" o.version)
82+ { preBuild = ""; buildPhase = ""; installPhase = "echo doing nothing"; }
83+ );
84+ patched-derivation = patched-derivation1.overrideAttrs (o:
85+ optionalAttrs (versions.isLe "8.7" coq.coq-version ||
86+ (o.version != "dev" && versions.isLe "1.7" o.version))
87+ {
88+ installFlags = o.installFlags ++ [ "-f Makefile.coq" ];
89+ }
90+ );
91+ in patched-derivation;
92in
93+mathcomp_ (if single then "single" else "all")
000000000000
-391
pkgs/development/coq-modules/mathcomp/extra.nix
···1-##########################################################
2-# Main derivation: #
3-# mathcomp-finmap mathcomp-analysis mathcomp-bigenough #
4-# mathcomp-multinomials mathcomp-real-closed coqeal #
5-# Additionally: #
6-# mathcomp-extra-all contains all the extra packages #
7-# mathcomp-extra-fast contains the one not marked slow #
8-########################################################################
9-# This file mainly provides the above derivations, which are packages #
10-# extra mathcomp libraries based on mathcomp. #
11-########################################################################
12-13-#####################################################
14-# Compiling customs versions using `mathcomp-extra` #
15-##############################################################################
16-# The prefered way to compile a custom version of mathcomp extra packages #
17-# (other than released versions which should be added to #
18-# `rec-mathcomp-extra-config` and pushed to nixpkgs, see below), #
19-# is to use `coqPackages.mathcomp-extra name version` where #
20-# 1. `name` is a string representing the name of a declared package #
21-# OR undeclared package. #
22-# 2. `version` is either: #
23-# - a string without slash, which is interpreted as a github revision, #
24-# i.e. either a tag, a branch or a commit hash #
25-# - a string with slashes "owner/p_1/.../p_n", which is interpreted as #
26-# github owner "owner" and revision "p_1/.../p_n". #
27-# - a path which is interpreted as a local source for the repository, #
28-# the name of the version is taken to be the basename of the path #
29-# i.e. if the path is /home/you/git/package/branch/, #
30-# then "branch" is the name of the version #
31-# - an attribute set which overrides some attributes (e.g. the src) #
32-# if the version is updated, the name is automatically regenerated using #
33-# the conventional schema "coq${coq.coq-version}-${pkgname}-${version}" #
34-# - a "standard" override function (old: new_attrs) to override the default #
35-# attribute set, so that you can use old.${field} to patch the derivation. #
36-# #
37-# Should you choose to use `pkg.overrideAttrs` instead, we provide the #
38-# function mathcomp-extra-override which takes a name and a version exactly #
39-# as above and returns an override function. #
40-##############################################################################
41-42-#########################################################################
43-# Example of use: https://github.com/math-comp/math-comp/wiki/Using-nix #
44-#########################################################################
45-46-###########################################
47-# Adding a new package or package version #
48-################################################################################
49-# 1. Update or add a `package` entry to `initial`, it must be a function #
50-# taking the version as argument and returning an attribute set. Everything #
51-# is optional and the default for the sources of the repository and the #
52-# homepage will be https://github.com/math-comp/${package}. #
53-# #
54-# 2. Update or add a `package` entry to `sha256` for each release. #
55-# You may use #
56-# ```sh #
57-# nix-prefetch-url --unpack #
58-# https://github.com/math-comp/math-comp/archive/version.tar.gz #
59-# ``` #
60-# #
61-# 3. Update or create a new consistent set of extra packages. #
62-# /!\ They must all be co-compatible. /!\ #
63-# Do not use versions that may disappear: it must either be #
64-# - a tag from the main repository (e.g. version or tag), or #
65-# - a revision hash that has been *merged in master* #
66-################################################################################
67-68-{ stdenv, fetchFromGitHub, recurseIntoAttrs,
69- which, mathcomp, coqPackages,
70- mathcomp-extra-config, mathcomp-extra-override,
71- mathcomp-extra, current-mathcomp-extra,
72-}:
73-with builtins // stdenv.lib;
74-let
75- ##############################
76- # CONFIGURATION, please edit #
77- ##############################
78- ############################
79- # Packages base delaration #
80- ############################
81- rec-mathcomp-extra-config = {
82- initial = {
83- mathcomp-finmap = {version, coqPackages}: {
84- meta = {
85- description = "A finset and finmap library";
86- repo = "finmap";
87- homepage = "https://github.com/math-comp/finmap";
88- };
89- passthru.compatibleCoqVersions = flip elem [ "8.8" "8.9" "8.10" "8.11" ];
90- };
91-92- mathcomp-bigenough = {version, coqPackages}: {
93- meta = {
94- description = "A small library to do epsilon - N reasonning";
95- repo = "bigenough";
96- homepage = "https://github.com/math-comp/bigenough";
97- };
98- passthru.compatibleCoqVersions = flip elem [ "8.7" "8.8" "8.9" "8.10" "8.11" ];
99- };
100-101- multinomials = {version, coqPackages}: {
102- buildInputs = [ which ];
103- propagatedBuildInputs = with coqPackages;
104- [ mathcomp.algebra mathcomp-finmap mathcomp-bigenough ];
105- meta = {
106- description = "A Coq/SSReflect Library for Monoidal Rings and Multinomials";
107- repo = "multinomials";
108- homepage = "https://github.com/math-comp/multinomials";
109- };
110- passthru.compatibleCoqVersions = flip elem [ "8.9" "8.10" "8.11" ];
111- };
112-113- mathcomp-analysis = {version, coqPackages}: {
114- propagatedBuildInputs = with coqPackages;
115- [ mathcomp.field mathcomp-finmap mathcomp-bigenough mathcomp-real-closed ];
116- meta = {
117- description = "Analysis library compatible with Mathematical Components";
118- homepage = "https://github.com/math-comp/analysis";
119- repo = "analysis";
120- license = stdenv.lib.licenses.cecill-c;
121- };
122- passthru.compatibleCoqVersions = flip elem ["8.8" "8.9" "8.10" "8.11" ];
123- };
124-125- mathcomp-real-closed = {version, coqPackages}: {
126- propagatedBuildInputs = with coqPackages;
127- [ mathcomp.field mathcomp-bigenough ];
128- meta = {
129- description = "Mathematical Components Library on real closed fields";
130- repo = "real-closed";
131- homepage = "https://github.com/math-comp/real-closed";
132- };
133- passthru.compatibleCoqVersions = flip elem ["8.8" "8.9" "8.10" "8.11" ];
134- };
135-136- coqeal = {version, coqPackages}: {
137- buildInputs = [ which ];
138- propagatedBuildInputs = with coqPackages;
139- [ mathcomp-algebra bignums paramcoq multinomials ];
140- meta = {
141- description = "CoqEAL - The Coq Effective Algebra Library";
142- homepage = "https://github.com/coqeal/coqeal";
143- license = stdenv.lib.licenses.mit;
144- owner = "CoqEAL";
145- };
146- passthru.compatibleCoqVersions = flip elem [ "8.9" "8.10" "8.11" ];
147- };
148- };
149-150- ###############################
151- # sha256 of released versions #
152- ###############################
153- sha256 = {
154- mathcomp-finmap = {
155- "1.5.0" = "0vx9n1fi23592b3hv5p5ycy7mxc8qh1y5q05aksfwbzkk5zjkwnq";
156- "1.4.1" = "0kx4nx24dml1igk0w0qijmw221r5bgxhwhl5qicnxp7ab3c35s8p";
157- "1.4.0+coq-8.11" = "1fd00ihyx0kzq5fblh9vr8s5mr1kg7p6pk11c4gr8svl1n69ppmb";
158- "1.4.0" = "0mp82mcmrs424ff1vj3cvd8353r9vcap027h3p0iprr1vkkwjbzd";
159- "1.3.4" = "0f5a62ljhixy5d7gsnwd66gf054l26k3m79fb8nz40i2mgp6l9ii";
160- "1.3.3" = "1n844zjhv354kp4g4pfbajix0plqh7yxv6471sgyb46885298am5";
161- "1.3.1" = "14rvm0rm5hd3pd0srgak3jqmddzfv6n7gdpjwhady5xcgrc7gsx7";
162- "1.2.1" = "0jryb5dq8js3imbmwrxignlk5zh8gwfb1wr4b1s7jbwz410vp7zf";
163- "1.2.0" = "0b6wrdr0d7rcnv86s37zm80540jl2wmiyf39ih7mw3dlwli2cyj4";
164- "1.1.0" = "05df59v3na8jhpsfp7hq3niam6asgcaipg2wngnzxzqnl86srp2a";
165- "1.0.0" = "0sah7k9qm8sw17cgd02f0x84hki8vj8kdz7h15i7rmz08rj0whpa";
166- };
167- mathcomp-bigenough = {
168- "1.0.0" = "10g0gp3hk7wri7lijkrqna263346wwf6a3hbd4qr9gn8hmsx70wg";
169- };
170- mathcomp-analysis = {
171- "0.3.1" = "1iad288yvrjv8ahl9v18vfblgqb1l5z6ax644w49w9hwxs93f2k8";
172- "0.3.0" = "03klwi4fja0cqb4myp3kgycfbmdv00bznmxf8yg3zzzzw997hjqc";
173- "0.2.3" = "0p9mr8g1qma6h10qf7014dv98ln90dfkwn76ynagpww7qap8s966";
174- "0.2.2" = "1d5dwg9di2ppdzfg21zr0a691zigb5kz0lcw263jpyli1nrq7cvk";
175- "0.2.0" = "1186xjxgns4ns1szyi931964bjm0mp126qzlv10mkqqgfw07nhrd";
176- "0.1.0" = "0hwkr2wzy710pcyh274fcarzdx8sv8myp16pv0vq5978nmih46al";
177- };
178- multinomials = {
179- "1.5.2" = "15aspf3jfykp1xgsxf8knqkxv8aav2p39c2fyirw7pwsfbsv2c4s";
180- "1.5.1" = "13nlfm2wqripaq671gakz5mn4r0xwm0646araxv0nh455p9ndjs3";
181- "1.5" = "064rvc0x5g7y1a0nip6ic91vzmq52alf6in2bc2dmss6dmzv90hw";
182- "1.4" = "0vnkirs8iqsv8s59yx1fvg1nkwnzydl42z3scya1xp1b48qkgn0p";
183- "1.3" = "0l3vi5n094nx3qmy66hsv867fnqm196r8v605kpk24gl0aa57wh4";
184- "1.2" = "1mh1w339dslgv4f810xr1b8v2w7rpx6fgk9pz96q0fyq49fw2xcq";
185- "1.1" = "1q8alsm89wkc0lhcvxlyn0pd8rbl2nnxg81zyrabpz610qqjqc3s";
186- "1.0" = "1qmbxp1h81cy3imh627pznmng0kvv37k4hrwi2faa101s6bcx55m";
187- };
188- mathcomp-real-closed = {
189- "1.1.1" = "0ksjscrgq1i79vys4zrmgvzy2y4ylxa8wdsf4kih63apw6v5ws6b";
190- "1.1.0" = "0zgfmrlximw77bw5w6w0xg2nampp02pmrwnrzx8m1n5pqljnv8fh";
191- "1.0.5" = "0q8nkxr9fba4naylr5xk7hfxsqzq2pvwlg1j0xxlhlgr3fmlavg2";
192- "1.0.4" = "058v9dj973h9kfhqmvcy9a6xhhxzljr90cf99hdfcdx68fi2ha1b";
193- "1.0.3" = "1xbzkzqgw5p42dx1liy6wy8lzdk39zwd6j14fwvv5735k660z7yb";
194- "1.0.2" = "0097pafwlmzd0gyfs31bxpi1ih04i72nxhn99r93aj20mn7mcsgl";
195- "1.0.1" = "0j81gkjbza5vg89v4n9z598mfdbql416963rj4b8fzm7dp2r4rxg";
196- };
197- coqeal = {
198- "1.0.4" = "1g5m26lr2lwxh6ld2gykailhay4d0ayql4bfh0aiwqpmmczmxipk";
199- "1.0.3" = "0hc63ny7phzbihy8l7wxjvn3haxx8jfnhi91iw8hkq8n29i23v24";
200- "1.0.2" = "1brmf3gj03iky1bcl3g9vx8vknny7xfvs0y2rfr85am0296sxsfj";
201- "1.0.1" = "19jhdrv2yp9ww0h8q73ihb2w1z3glz4waf2d2n45klafxckxi7bm";
202- "1.0.0" = "1had6f1n85lmh9x31avbmgl3m0rsiw9f8ma95qzk5b57fjg5k1ii";
203- };
204- };
205-206- ################################
207- # CONSISTENT sets of packages. #
208- ################################
209- for-coq-and-mc = let
210- v6 = {
211- mathcomp-finmap = "1.5.0";
212- mathcomp-bigenough = "1.0.0";
213- mathcomp-analysis = "0.3.1";
214- multinomials = "1.5.2";
215- mathcomp-real-closed = "1.1.1";
216- coqeal = "1.0.4";
217- };
218- v5 = {
219- mathcomp-finmap = "1.5.0";
220- mathcomp-bigenough = "1.0.0";
221- mathcomp-analysis = "0.3.0";
222- multinomials = "1.5.1";
223- mathcomp-real-closed = "1.0.5";
224- coqeal = "1.0.4";
225- };
226- v4 = v3 // { coqeal = "1.0.3"; };
227- v3 = {
228- mathcomp-finmap = "1.4.0";
229- mathcomp-bigenough = "1.0.0";
230- mathcomp-analysis = "0.2.3";
231- multinomials = "1.5";
232- mathcomp-real-closed = "1.0.4";
233- coqeal = "1.0.0";
234- };
235- v2 = {
236- mathcomp-finmap = "1.3.4";
237- mathcomp-bigenough = "1.0.0";
238- mathcomp-analysis = "0.2.3";
239- multinomials = "1.4";
240- mathcomp-real-closed = "1.0.3";
241- coqeal = "1.0.0";
242- };
243- v1 = {
244- mathcomp-finmap = "1.1.0";
245- mathcomp-bigenough = "1.0.0";
246- multinomials = "1.1";
247- mathcomp-real-closed = "1.0.1";
248- coqeal = "1.0.0";
249- };
250- in
251- {
252- "8.11" = {
253- "1.11.0" = v6;
254- "1.11+beta1" = v5;
255- "1.10.0" = v4 // {mathcomp-finmap = "1.4.0+coq-8.11";};
256- };
257- "8.10" = {
258- "1.11.0" = removeAttrs v6 ["coqeal"];
259- "1.11+beta1" = removeAttrs v5 ["coqeal"];
260- "1.10.0" = v4;
261- "1.9.0" = removeAttrs v3 ["coqeal"];
262- };
263- "8.9" = {
264- "1.11.0" = removeAttrs v6 ["mathcomp-analysis"];
265- "1.11+beta1" = removeAttrs v5 ["mathcomp-analysis"];
266- "1.10.0" = v4;
267- "1.9.0" = removeAttrs v3 ["coqeal"];
268- "1.8.0" = removeAttrs v2 ["coqeal"];
269- };
270- "8.8" = {
271- "1.11.0" = removeAttrs v6 ["mathcomp-analysis"];
272- "1.11+beta1" = removeAttrs v5 ["mathcomp-analysis"];
273- "1.10.0" = removeAttrs v4 ["mathcomp-analysis"];
274- "1.9.0" = removeAttrs v3 ["coqeal"];
275- "1.8.0" = removeAttrs v2 ["coqeal"];
276- "1.7.0" = removeAttrs v1 ["coqeal" "multinomials"];
277- };
278- "8.7" = {
279- "1.11.0" = removeAttrs v6 ["mathcomp-analysis"];
280- "1.11+beta1" = removeAttrs v5 ["mathcomp-analysis"];
281- "1.10.0" = removeAttrs v4 ["mathcomp-analysis"];
282- "1.9.0" = removeAttrs v3 ["coqeal" "mathcomp-analysis"];
283- "1.8.0" = removeAttrs v2 ["coqeal" "mathcomp-analysis"];
284- "1.7.0" = removeAttrs v1 ["coqeal" "multinomials"];
285- };
286- };
287- };
288-289- ##############################
290- # GENERATION, EDIT WITH CARE #
291- ##############################
292- coq = coqPackages.coq;
293-294- default-attrs = {
295- version = "master";
296- buildInputs = [];
297- propagatedBuildInputs = (with coqPackages; [ ssreflect ]);
298- installFlags = [ "-f" "Makefile.coq" "COQLIB=$(out)/lib/coq/${coq.coq-version}/" ];
299- meta = {
300- inherit (mathcomp.meta) platforms license;
301- owner = "math-comp";
302- maintainers = [ maintainers.vbgl maintainers.cohencyril ];
303- };
304- passthru.compatibleCoqVersions = (_: true);
305- };
306-307- pkgUp = recursiveUpdateUntil (path: l: r: !(isAttrs l && isAttrs r) || path == ["src"]);
308-309- # Fixes a partial attribute set using the configuration
310- # in the style of the above mathcomp-extra-config.initial,
311- # and generates a name according to the conventional naming scheme below
312- fix-attrs = pkgcfg:
313- let attrs = pkgUp default-attrs pkgcfg; in
314- pkgUp attrs (rec {
315- name = "coq${coq.coq-version}mathcomp${mathcomp.version}-${attrs.meta.repo or attrs.meta.package or "anonymous"}-${attrs.version}";
316- src = attrs.src or (fetchTarball "${meta.homepage}/archive/${attrs.version}.tar.gz");
317- meta = rec {
318- homepage = attrs.meta.homepage or attrs.src.meta.homepage or "https://github.com/${owner}/${repo}";
319- owner = attrs.meta.owner or "math-comp";
320- repo = attrs.meta.repo or attrs.meta.package or "math-comp-nix";
321- };
322- });
323-324- # Gets a version out of a string, path or attribute set.
325- getVersion = arg:
326- if isFunction arg then (arg {}).version
327- else if arg == "" then "master"
328- else if isDerivation arg then arg.drvAttrs.version or "master"
329- else if isAttrs arg then arg.version or "master"
330- else if isString arg then head (reverseList (split "/" arg))
331- else if isPath arg then (baseNameOf arg)
332- else "master";
333-334- # Converts a string, path or attribute set into an override function
335- # It tries to fill the `old` argument of the override function using
336- # `mathcomp-extra-config.initial` first and finishes with `fix-attrs`
337- rec-mathcomp-extra-override = generic: old: let
338- version = getVersion generic;
339- package = old.meta.package or "math-comp-nix";
340- cfg = pkgUp ((mathcomp-extra-config.initial.${package} or (_: {}))
341- { inherit version coqPackages; }) old
342- // { inherit version; };
343- fix = attrs: fix-attrs (pkgUp cfg attrs);
344- in
345- if isFunction generic then fix (generic cfg)
346- else if generic == null || generic == "" then fix {}
347- else if isDerivation generic then generic.drvAttrs
348- else if isAttrs generic then fix generic
349- else if generic == "broken" then fix { meta.broken = true; passthru.compatibleCoqVersions = _: false; }
350- else let fixedcfg = fix cfg; in fixedcfg // (
351- if isString generic then
352- if (mathcomp-extra-config.sha256.${package} or {})?${generic} then {
353- src = fetchFromGitHub {
354- inherit (fixedcfg.meta) owner repo;
355- rev = version;
356- sha256 = mathcomp-extra-config.sha256.${package}.${version};
357- };
358- }
359- else let splitted = filter isString (split "/" generic); in {
360- src = fetchTarball
361- ("https://github.com/" +
362- (if length splitted == 1 then "${fixedcfg.meta.owner}/${fixedcfg.meta.repo}/archive/${version}.tar.gz"
363- else "${head splitted}/${fixedcfg.meta.repo}/archive/${concatStringsSep "/" (tail splitted)}.tar.gz"));
364- }
365- else if isPath generic then { src = generic; }
366- else abort "${toString generic} not a legitimate generic version/override");
367-368- # applies mathcomp-extra-config.for-coq-and-mc to the current mathcomp version
369- for-this = mathcomp-extra-config.for-coq-and-mc.${coq.coq-version}.${mathcomp.version} or {};
370-371- # specializes mathcomp-extra to the current mathcomp version.
372- rec-current-mathcomp-extra = package: mathcomp-extra package (for-this.${package} or {});
373-in
374- {
375- mathcomp-extra-override = rec-mathcomp-extra-override;
376- mathcomp-extra-config = rec-mathcomp-extra-config;
377- current-mathcomp-extra = rec-current-mathcomp-extra;
378- mathcomp-extra = package: version:
379- stdenv.mkDerivation (mathcomp-extra-override version {meta = {inherit package;};});
380-381- mathcomp-finmap = current-mathcomp-extra "mathcomp-finmap";
382- mathcomp-analysis = current-mathcomp-extra "mathcomp-analysis";
383- mathcomp-bigenough = current-mathcomp-extra "mathcomp-bigenough";
384- multinomials = current-mathcomp-extra "multinomials";
385- mathcomp-real-closed = current-mathcomp-extra "mathcomp-real-closed";
386- coqeal = current-mathcomp-extra "coqeal";
387-388- mathcomp-extra-fast = map current-mathcomp-extra
389- (attrNames (filterAttrs (pkg: config: !(config?slow && config.slow)) for-this));
390- mathcomp-extra-all = map current-mathcomp-extra (attrNames for-this);
391- }
···1+{ stdenv, lib, fetchFromGitHub, fetchpatch, pkg-config, cmake, git, doxygen, help2man, ncurses, tecla
2, libusb1, udev }:
34let
···22 rev = "libbladeRF_v${version}";
23 sha256 = "0g89al4kwfbx1l3zjddgb9ay4mhr7zk0ndchca3sm1vq2j47nf4l";
24 };
25+26+ # This patch is required for version 2.2.1. As the patch is already part of
27+ # upstream master, it will be incorporated into the next release. The patch
28+ # fixes a (well-justified) compiler warning which breaks the build because
29+ # we compile with -Werror.
30+ patches = [ (fetchpatch {
31+ url = "https://github.com/Nuand/bladeRF/commit/163425d48a3b7d8c100d7295220d3648c050d0dd.patch";
32+ sha256 = "1swsymlyxm3yk2k8l71z1fv0a5k2rmab02f0c7xkrvk683mq6yxw";
33+ }) ];
3435 nativeBuildInputs = [ cmake pkg-config git doxygen help2man ];
36 # ncurses used due to https://github.com/Nuand/bladeRF/blob/ab4fc672c8bab4f8be34e8917d3f241b1d52d0b8/host/utilities/bladeRF-cli/CMakeLists.txt#L208