summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDennis Gosnell <cdep.illabout@gmail.com>2022-09-16 09:09:09 -0400
committerGitHub <noreply@github.com>2022-09-16 09:09:09 -0400
commit533e1f0468e7ff46b7763e982ae9c6741ee843cf (patch)
treecab535f31caa5ddea3d2f433bc56a2ee5a4cfcd1
parent2bc1ab2917d10dd83917aab4942216109158b1cb (diff)
parent6cc6850fe23dbd85609c38796dc2f290aed06ccc (diff)
Merge pull request #190795 from cdepillabout/coq-add-docs
doc/language-frameworks/coq: add explanation of how to override packages
-rw-r--r--doc/languages-frameworks/coq.section.md55
1 files changed, 55 insertions, 0 deletions
diff --git a/doc/languages-frameworks/coq.section.md b/doc/languages-frameworks/coq.section.md
index 901332a7d34f..38bf7db18506 100644
--- a/doc/languages-frameworks/coq.section.md
+++ b/doc/languages-frameworks/coq.section.md
@@ -88,3 +88,58 @@ with lib; mkCoqDerivation {
};
}
```
+
+## Three ways of overriding Coq packages {#coq-overriding-packages}
+
+There are three distinct ways of changing a Coq package by overriding one of its values: `.override`, `overrideCoqDerivation`, and `.overrideAttrs`. This section explains what sort of values can be overridden with each of these methods.
+
+### `.override` {#coq-override}
+
+`.override` lets you change arguments to a Coq derivation. In the case of the `multinomials` package above, `.override` would let you override arguments like `mkCoqDerivation`, `version`, `coq`, `mathcomp`, `mathcom-finmap`, etc.
+
+For example, assuming you have a special `mathcomp` dependency you want to use, here is how you could override the `mathcomp` dependency:
+
+```nix
+multinomials.override {
+ mathcomp = my-special-mathcomp;
+}
+```
+
+In Nixpkgs, all Coq derivations take a `version` argument. This can be overridden in order to easily use a different version:
+
+```nix
+coqPackages.multinomials.override {
+ version = "1.5.1";
+}
+```
+
+Refer to [](#coq-packages-attribute-sets-coqpackages) for all the different formats that you can potentially pass to `version`, as well as the restrictions.
+
+### `overrideCoqDerivation` {#coq-overrideCoqDerivation}
+
+The `overrideCoqDerivation` function lets you easily change arguments to `mkCoqDerivation`. These arguments are described in [](#coq-packages-attribute-sets-coqpackages).
+
+For example, here is how you could locally add a new release of the `multinomials` library, and set the `defaultVersion` to use this release:
+
+```nix
+coqPackages.lib.overrideCoqDerivation
+ {
+ defaultVersion = "2.0";
+ release."2.0".sha256 = "1lq8x86vd3vqqh2yq6hvyagpnhfq5wmk5pg2z0xq7b7dbbbhyfkk";
+ }
+ coqPackages.multinomials
+```
+
+### `.overrideAttrs` {#coq-overrideAttrs}
+
+`.overrideAttrs` lets you override arguments to the underlying `stdenv.mkDerivation` call. Internally, `mkCoqDerivation` uses `stdenv.mkDerivation` to create derivations for Coq libraries. You can override arguments to `stdenv.mkDerivation` with `.overrideAttrs`.
+
+For instance, here is how you could add some code to be performed in the derivation after installation is complete:
+
+```nix
+coqPackages.multinomials.overrideAttrs (oldAttrs: {
+ postInstall = oldAttrs.postInstall or "" + ''
+ echo "you can do anything you want here"
+ '';
+})
+```