From 20291381c1e79eda0d5efbf3470440f270a7dee6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Zimmermann?= Date: Tue, 7 Sep 2021 14:44:40 +0200 Subject: [PATCH] coqPackages.mkCoqDerivation: rely on namePrefix to compute default opam-name As suggested by Cyril Cohen in https://github.com/NixOS/nixpkgs/pull/134362#discussion_r698379405. --- doc/languages-frameworks/coq.section.md | 4 ++-- pkgs/build-support/coq/default.nix | 5 ++--- pkgs/development/coq-modules/multinomials/default.nix | 1 - 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/doc/languages-frameworks/coq.section.md b/doc/languages-frameworks/coq.section.md index 39b60d83ac7d..a5155aedaf52 100644 --- a/doc/languages-frameworks/coq.section.md +++ b/doc/languages-frameworks/coq.section.md @@ -28,12 +28,12 @@ The recommended way of defining a derivation for a Coq library, is to use the `c * `domain` (optional, defaults to `"github.com"`), domains including the strings `"github"` or `"gitlab"` in their names are automatically supported, otherwise, one must change the `fetcher` argument to support them (cf `pkgs/development/coq-modules/heq/default.nix` for an example), * `releaseRev` (optional, defaults to `(v: v)`), provides a default mapping from release names to revision hashes/branch names/tags, * `displayVersion` (optional), provides a way to alter the computation of `name` from `pname`, by explaining how to display version numbers, -* `namePrefix` (optional), provides a way to alter the computation of `name` from `pname`, by explaining which dependencies must occur in `name`, +* `namePrefix` (optional, defaults to `[ "coq" ]`), provides a way to alter the computation of `name` from `pname`, by explaining which dependencies must occur in `name`, * `extraBuildInputs` (optional), by default `buildInputs` just contains `coq`, this allows to add more build inputs, * `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. * `useDune2ifVersion` (optional, default to `(x: false)` uses Dune2 to build the package if the provided predicate evaluates to true on the version, e.g. `useDune2if = versions.isGe "1.1"` will use dune if the version of the package is greater or equal to `"1.1"`, * `useDune2` (optional, defaults to `false`) uses Dune2 to build the package if set to true, the presence of this attribute overrides the behavior of the previous one. -* `opam-name` (optional, defaults to `coq-` followed by the value of `pname`), name of the Dune package to build. +* `opam-name` (optional, defaults to concatenating with a dash separator the components of `namePrefix` and `pname`), name of the Dune package to build. * `enableParallelBuilding` (optional, defaults to `true`), since it is activated by default, we provide a way to disable it. * `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. * `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`, diff --git a/pkgs/build-support/coq/default.nix b/pkgs/build-support/coq/default.nix index 05f6e7762a07..569b07cded63 100644 --- a/pkgs/build-support/coq/default.nix +++ b/pkgs/build-support/coq/default.nix @@ -16,7 +16,7 @@ in displayVersion ? {}, release ? {}, extraBuildInputs ? [], - namePrefix ? [], + namePrefix ? [ "coq" ], enableParallelBuilding ? true, extraInstallFlags ? [], setCOQBIN ? true, @@ -27,7 +27,7 @@ in dropDerivationAttrs ? [], useDune2ifVersion ? (x: false), useDune2 ? false, - opam-name ? "coq-${pname}", + opam-name ? (concatStringsSep "-" (namePrefix ++ [ pname ])), ... }@args: let @@ -44,7 +44,6 @@ let location = { inherit domain owner repo; }; } // optionalAttrs (args?fetcher) {inherit fetcher;}); fetched = fetch (if !isNull version then version else defaultVersion); - namePrefix = args.namePrefix or [ "coq" ]; display-pkg = n: sep: v: let d = displayVersion.${n} or (if sep == "" then ".." else true); in n + optionalString (v != "" && v != null) (switch d [ diff --git a/pkgs/development/coq-modules/multinomials/default.nix b/pkgs/development/coq-modules/multinomials/default.nix index acbb602a54ef..f806d764755d 100644 --- a/pkgs/development/coq-modules/multinomials/default.nix +++ b/pkgs/development/coq-modules/multinomials/default.nix @@ -4,7 +4,6 @@ with lib; mkCoqDerivation { namePrefix = [ "coq" "mathcomp" ]; pname = "multinomials"; - opam-name = "coq-mathcomp-multinomials"; owner = "math-comp";