-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
ocamlPackages.buildDunePackage: support fixed point args with lib.extendMkDerivation
#446007
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,82 +8,83 @@ | |
| dune_3, | ||
| }: | ||
|
|
||
| { | ||
| pname, | ||
| version, | ||
| nativeBuildInputs ? [ ], | ||
| enableParallelBuilding ? true, | ||
| ... | ||
| }@args: | ||
| lib.extendMkDerivation { | ||
| constructDrv = stdenv.mkDerivation; | ||
| excludeDrvArgNames = [ | ||
| "minimalOCamlVersion" | ||
| "duneVersion" | ||
| ]; | ||
|
Comment on lines
+13
to
+16
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason why these have been excluded? it could be useful to know and access this information.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. This is meta-data that MUST NOT affect the hash.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. What about inheriting them in passthru similar to what the python builder does? |
||
| extendDrvArgs = | ||
| finalAttrs: | ||
| { | ||
| pname, | ||
| version, | ||
| nativeBuildInputs ? [ ], | ||
| enableParallelBuilding ? true, | ||
| ... | ||
| }@args: | ||
|
|
||
| let | ||
| Dune = | ||
| let | ||
| dune-version = args.duneVersion or "3"; | ||
| Dune = | ||
| let | ||
| dune-version = args.duneVersion or "3"; | ||
| in | ||
| { | ||
| "1" = dune_1; | ||
| "2" = dune_2; | ||
| "3" = dune_3; | ||
| } | ||
| ."${dune-version}"; | ||
| in | ||
| { | ||
| "1" = dune_1; | ||
| "2" = dune_2; | ||
| "3" = dune_3; | ||
| } | ||
| ."${dune-version}"; | ||
| stdenv' = args.stdenv or stdenv; | ||
| in | ||
|
|
||
| if args ? minimalOCamlVersion && lib.versionOlder ocaml.version args.minimalOCamlVersion then | ||
| throw "${pname}-${version} is not available for OCaml ${ocaml.version}" | ||
| else | ||
| if args ? minimalOCamlVersion && lib.versionOlder ocaml.version args.minimalOCamlVersion then | ||
| throw "${pname}-${version} is not available for OCaml ${ocaml.version}" | ||
| else | ||
| { | ||
| name = "ocaml${ocaml.version}-${pname}-${version}"; | ||
|
|
||
| stdenv'.mkDerivation ( | ||
| { | ||
|
|
||
| inherit enableParallelBuilding; | ||
| dontAddStaticConfigureFlags = true; | ||
| configurePlatforms = [ ]; | ||
| strictDeps = true; | ||
|
|
||
| buildPhase = '' | ||
| runHook preBuild | ||
| dune build -p ${pname} ''${enableParallelBuilding:+-j $NIX_BUILD_CORES} | ||
| runHook postBuild | ||
| ''; | ||
| checkPhase = '' | ||
| runHook preCheck | ||
| dune runtest -p ${pname} ''${enableParallelBuilding:+-j $NIX_BUILD_CORES} | ||
| runHook postCheck | ||
| ''; | ||
| installPhase = '' | ||
| runHook preInstall | ||
| dune install --prefix $out --libdir $OCAMLFIND_DESTDIR ${pname} \ | ||
| ${ | ||
| if lib.versionAtLeast Dune.version "2.9" then | ||
| "--docdir $out/share/doc --mandir $out/share/man" | ||
| else | ||
| "" | ||
| } | ||
| runHook postInstall | ||
| ''; | ||
| inherit enableParallelBuilding; | ||
| dontAddStaticConfigureFlags = true; | ||
| configurePlatforms = [ ]; | ||
|
|
||
| strictDeps = true; | ||
| nativeBuildInputs = [ | ||
| ocaml | ||
| Dune | ||
| findlib | ||
| ] | ||
| ++ nativeBuildInputs; | ||
|
|
||
| } | ||
| // (builtins.removeAttrs args [ | ||
| "minimalOCamlVersion" | ||
| "duneVersion" | ||
| ]) | ||
| // { | ||
| buildPhase = | ||
| args.buildPhase or '' | ||
| runHook preBuild | ||
| dune build -p ${pname} ''${enableParallelBuilding:+-j $NIX_BUILD_CORES} | ||
| runHook postBuild | ||
| ''; | ||
|
|
||
| name = "ocaml${ocaml.version}-${pname}-${version}"; | ||
| installPhase = | ||
| args.installPhase or '' | ||
| runHook preInstall | ||
| dune install --prefix $out --libdir $OCAMLFIND_DESTDIR ${pname} \ | ||
| ${ | ||
| if lib.versionAtLeast Dune.version "2.9" then | ||
| "--docdir $out/share/doc --mandir $out/share/man" | ||
| else | ||
| "" | ||
| } | ||
| runHook postInstall | ||
| ''; | ||
|
|
||
| nativeBuildInputs = [ | ||
| ocaml | ||
| Dune | ||
| findlib | ||
| ] | ||
| ++ nativeBuildInputs; | ||
| checkPhase = | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tried defaulting might need to set it to false explicitly in those pkgs before defaulting this to true here |
||
| args.checkPhase or '' | ||
| runHook preCheck | ||
| dune runtest -p ${pname} ''${enableParallelBuilding:+-j $NIX_BUILD_CORES} | ||
| runHook postCheck | ||
| ''; | ||
|
|
||
| meta = (args.meta or { }) // { | ||
| platforms = args.meta.platforms or ocaml.meta.platforms; | ||
| meta = (args.meta or { }) // { | ||
| platforms = args.meta.platforms or ocaml.meta.platforms; | ||
| }; | ||
| }; | ||
|
|
||
| } | ||
| ) | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i haven't figure out with a way to replicate this behavior (
stdenv' = args.stdenv or stdenv;) without adding another argument abovelib.extendMkDerivation, but it seems that no in-tree code depends on this...i personally think it'd be fine leaving this as is