Skip to content

Latest commit

 

History

History
35 lines (22 loc) · 1.9 KB

missing-phase-hooks.md

File metadata and controls

35 lines (22 loc) · 1.9 KB

If you are overriding configurePhase, buildPhase, checkPhase, installPhase or any other phase, you should not forget about explicitly running pre and post-phase hooks like their original definitions do.

It is generally expected that an appropriate pre-phase hook (e.g. preBuild) hook will run at the beginning of a phase (e.g. buildPhase) and post-phase hook (e.g. postBuild) will run at the end. Hooks are normally ran as a part of a phase so if you override a phase as a whole, you will need to add runHook hookName calls (e.g. runHook preBuild) manually.

Having phases run pre/post-phase hooks is important because many setup hooks insert their own code into them – omitting a hook might therefore prevent some setup hooks required for proper functionality of a package from running. Additionally, hooks are often inserted by developers into the package expression and by users when overriding a package using overrideAttrs. Not running them can thus cause confusion why their code is not executed.

Examples

Before

  installPhase = ''
    your commands
  '';

After

  installPhase = ''
    runHook preInstall

    your commands

    runHook postInstall
  '';

Alternatives

And if you just want to add a flag to make call, you might not even need to override the phases, see explicit-phases rule.

See also