2020-08-28 21:05:46 +00:00
|
|
|
{ lib, stdenv, coqPackages, coq, fetchzip }@args:
|
|
|
|
let lib = import ./extra-lib.nix {inherit (args) lib;}; in
|
|
|
|
with builtins; with lib;
|
|
|
|
let
|
|
|
|
isGitHubDomain = d: match "^github.*" d != null;
|
|
|
|
isGitLabDomain = d: match "^gitlab.*" d != null;
|
|
|
|
in
|
|
|
|
{ pname,
|
|
|
|
version ? null,
|
|
|
|
fetcher ? null,
|
|
|
|
owner ? "coq-community",
|
|
|
|
domain ? "github.com",
|
|
|
|
repo ? pname,
|
|
|
|
defaultVersion ? null,
|
|
|
|
releaseRev ? (v: v),
|
|
|
|
displayVersion ? {},
|
|
|
|
release ? {},
|
|
|
|
extraBuildInputs ? [],
|
2022-02-24 14:01:15 +00:00
|
|
|
extraNativeBuildInputs ? [],
|
2021-09-07 12:44:40 +00:00
|
|
|
namePrefix ? [ "coq" ],
|
2020-08-28 21:05:46 +00:00
|
|
|
enableParallelBuilding ? true,
|
|
|
|
extraInstallFlags ? [],
|
|
|
|
setCOQBIN ? true,
|
|
|
|
mlPlugin ? false,
|
|
|
|
useMelquiondRemake ? null,
|
|
|
|
dropAttrs ? [],
|
|
|
|
keepAttrs ? [],
|
|
|
|
dropDerivationAttrs ? [],
|
2021-03-10 15:25:32 +00:00
|
|
|
useDune2ifVersion ? (x: false),
|
|
|
|
useDune2 ? false,
|
2021-09-07 12:44:40 +00:00
|
|
|
opam-name ? (concatStringsSep "-" (namePrefix ++ [ pname ])),
|
2020-08-28 21:05:46 +00:00
|
|
|
...
|
|
|
|
}@args:
|
|
|
|
let
|
|
|
|
args-to-remove = foldl (flip remove) ([
|
|
|
|
"version" "fetcher" "repo" "owner" "domain" "releaseRev"
|
|
|
|
"displayVersion" "defaultVersion" "useMelquiondRemake"
|
2022-02-24 14:01:15 +00:00
|
|
|
"release" "extraBuildInputs" "extraNativeBuildInputs" "extraPropagatedBuildInputs" "namePrefix"
|
2021-08-16 20:38:17 +00:00
|
|
|
"meta" "useDune2ifVersion" "useDune2" "opam-name"
|
2020-08-28 21:05:46 +00:00
|
|
|
"extraInstallFlags" "setCOQBIN" "mlPlugin"
|
|
|
|
"dropAttrs" "dropDerivationAttrs" "keepAttrs" ] ++ dropAttrs) keepAttrs;
|
|
|
|
fetch = import ../coq/meta-fetch/default.nix
|
2021-01-27 10:21:31 +00:00
|
|
|
{ inherit lib stdenv fetchzip; } ({
|
2020-08-28 21:05:46 +00:00
|
|
|
inherit release releaseRev;
|
|
|
|
location = { inherit domain owner repo; };
|
|
|
|
} // optionalAttrs (args?fetcher) {inherit fetcher;});
|
|
|
|
fetched = fetch (if !isNull version then version else defaultVersion);
|
|
|
|
display-pkg = n: sep: v:
|
|
|
|
let d = displayVersion.${n} or (if sep == "" then ".." else true); in
|
|
|
|
n + optionalString (v != "" && v != null) (switch d [
|
|
|
|
{ case = true; out = sep + v; }
|
|
|
|
{ case = "."; out = sep + versions.major v; }
|
|
|
|
{ case = ".."; out = sep + versions.majorMinor v; }
|
|
|
|
{ case = "..."; out = sep + versions.majorMinorPatch v; }
|
|
|
|
{ case = isFunction; out = optionalString (d v != "") (sep + d v); }
|
|
|
|
{ case = isString; out = optionalString (d != "") (sep + d); }
|
|
|
|
] "") + optionalString (v == null) "-broken";
|
|
|
|
append-version = p: n: p + display-pkg n "" coqPackages.${n}.version + "-";
|
|
|
|
prefix-name = foldl append-version "" namePrefix;
|
2021-09-06 14:56:12 +00:00
|
|
|
var-coqlib-install =
|
|
|
|
(optionalString (versions.isGe "8.7" coq.coq-version || coq.coq-version == "dev") "COQMF_") + "COQLIB";
|
2021-06-09 13:14:17 +00:00
|
|
|
useDune2 = args.useDune2 or (useDune2ifVersion fetched.version);
|
2020-08-28 21:05:46 +00:00
|
|
|
in
|
|
|
|
|
|
|
|
stdenv.mkDerivation (removeAttrs ({
|
|
|
|
|
|
|
|
name = prefix-name + (display-pkg pname "-" fetched.version);
|
|
|
|
|
|
|
|
inherit (fetched) version src;
|
|
|
|
|
2022-02-24 14:01:15 +00:00
|
|
|
nativeBuildInputs = [ coq ]
|
2021-03-10 15:25:32 +00:00
|
|
|
++ optionals useDune2 [coq.ocaml coq.ocamlPackages.dune_2]
|
2022-02-24 14:01:15 +00:00
|
|
|
++ optionals mlPlugin coq.ocamlNativeBuildInputs
|
|
|
|
++ extraNativeBuildInputs;
|
|
|
|
buildInputs = optionals mlPlugin coq.ocamlBuildInputs
|
2021-03-10 15:25:32 +00:00
|
|
|
++ extraBuildInputs;
|
2020-08-28 21:05:46 +00:00
|
|
|
inherit enableParallelBuilding;
|
|
|
|
|
|
|
|
meta = ({ platforms = coq.meta.platforms; } //
|
|
|
|
(switch domain [{
|
|
|
|
case = pred.union isGitHubDomain isGitLabDomain;
|
|
|
|
out = { homepage = "https://${domain}/${owner}/${repo}"; };
|
|
|
|
}] {}) //
|
|
|
|
optionalAttrs (fetched.broken or false) { coqFilter = true; broken = true; }) //
|
|
|
|
(args.meta or {}) ;
|
|
|
|
|
2021-03-10 15:25:32 +00:00
|
|
|
}
|
|
|
|
// (optionalAttrs setCOQBIN { COQBIN = "${coq}/bin/"; })
|
|
|
|
// (optionalAttrs (!args?installPhase && !args?useMelquiondRemake) {
|
2020-08-28 21:05:46 +00:00
|
|
|
installFlags =
|
|
|
|
[ "${var-coqlib-install}=$(out)/lib/coq/${coq.coq-version}/" ] ++
|
|
|
|
optional (match ".*doc$" (args.installTargets or "") != null)
|
|
|
|
"DOCDIR=$(out)/share/coq/${coq.coq-version}/" ++
|
|
|
|
extraInstallFlags;
|
2021-03-10 15:25:32 +00:00
|
|
|
})
|
|
|
|
// (optionalAttrs useDune2 {
|
2021-08-16 20:38:17 +00:00
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
|
|
|
dune build -p ${opam-name} ''${enableParallelBuilding:+-j $NIX_BUILD_CORES}
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
2021-03-10 15:25:32 +00:00
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
2021-08-16 20:38:17 +00:00
|
|
|
dune install ${opam-name} --prefix=$out
|
2021-03-10 15:25:32 +00:00
|
|
|
mv $out/lib/coq $out/lib/TEMPORARY
|
|
|
|
mkdir $out/lib/coq/
|
|
|
|
mv $out/lib/TEMPORARY $out/lib/coq/${coq.coq-version}
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
})
|
|
|
|
// (optionalAttrs (args?useMelquiondRemake) rec {
|
2020-08-28 21:05:46 +00:00
|
|
|
COQUSERCONTRIB = "$out/lib/coq/${coq.coq-version}/user-contrib";
|
|
|
|
preConfigurePhases = "autoconf";
|
|
|
|
configureFlags = [ "--libdir=${COQUSERCONTRIB}/${useMelquiondRemake.logpath or ""}" ];
|
|
|
|
buildPhase = "./remake -j$NIX_BUILD_CORES";
|
|
|
|
installPhase = "./remake install";
|
2021-03-10 15:25:32 +00:00
|
|
|
})
|
|
|
|
// (removeAttrs args args-to-remove)) dropDerivationAttrs)
|