Home Explore Blog CI



nixpkgs

5th chunk of `doc/languages-frameworks/coq.section.md`
37b0cdf5bb8b559f210c9dd745bfd5f6f1ce5e8f37cee6950000000100000e96
            (range "8.7" "8.12")
            (isEq "1.11")
          ];
          out = "1.5.2";
        }
        {
          cases = [
            (range "8.7" "8.11")
            (range "1.8" "1.10")
          ];
          out = "1.5.0";
        }
        {
          cases = [
            (range "8.7" "8.10")
            (range "1.8" "1.10")
          ];
          out = "1.4";
        }
        {
          cases = [
            (isEq "8.6")
            (range "1.6" "1.7")
          ];
          out = "1.1";
        }
      ]
      null;
  release = {
    "1.5.2".hash = "sha256-mjCx9XKa38Nz9E6wNK7YSqHdJ7YTua5fD3d6J4e7WpU=";
    "1.5.1".hash = "sha256-Q8tm0y2FQAt2V1kZYkDlHWRia/lTvXAMVjdmzEV11I4=";
    "1.5.0".hash = "sha256-HIK0f21G69oEW8JG46gSBde/Q2LR3GiBCv680gHbmRg=";
    "1.5.0".rev = "1.5";
    "1.4".hash = "sha256-F9g3MSIr3B6UZ3p8QWjz3/Jpw9sudJ+KRlvjiHSO024=";
    "1.3".hash = "sha256-BPJTlAL0ETHvLMBslE0KFVt3DNoaGuMrHt2SBGyJe1A=";
    "1.2".hash = "sha256-mHXBXSLYO4BN+jfN50y/+XCx0Qq5g4Ac2Y/qlsbgAdY=";
    "1.1".hash = "sha256-ejAsMQbB/LtU9j+g160VdGXULrCe9s0gBWzyhKqmCuE=";
    "1.0".hash = "sha256-tZTOltEBBKWciDxDMs/Ye4Jnq/33CANrHJ4FBMPtq+I=";
  };

  propagatedBuildInputs = [
    mathcomp.ssreflect
    mathcomp.algebra
    mathcomp-finmap
    mathcomp-bigenough
  ];

  meta = {
    description = "Coq/SSReflect Library for Monoidal Rings and Multinomials";
    license = lib.licenses.cecill-c;
  };
}
```

## 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".hash = "sha256-czoP11rtrIM7+OLdMisv2EF7n/IbGuwFxHiPtg3qCNM=";
} 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"
    '';
})
```

Title: Coq Package Example and Overriding Methods
Summary
This section provides a complete example of a Coq package definition, including version-specific configurations, dependencies, and metadata. It then details three methods for overriding Coq packages in Nixpkgs: `.override` for changing arguments to a Coq derivation, `overrideCoqDerivation` for modifying arguments to `mkCoqDerivation`, and `.overrideAttrs` for customizing the underlying `stdenv.mkDerivation` call. Examples are given for each method to illustrate their usage.