What does `runHook` do?

The function runHook is often used in packages, but there doesn’t seem to be documentation anywhere.
I have usually seen before and after package phases, i.e.:

installPhase = ''
  runHook preInstall

  foobar

  runHook postInstall
'';

Will those hooks not run unless they are called using runHook?
Can I create arbitrary hook names?

1 Like

So if those hooks were not called in the phase script, they will not run, right?
I.e.

preInstall = ''
  echo "I will be called";
'';

installPhase = ''
  runHook preInstall
'';

postInstall = ''
  echo "I will NEVER be called";
'';

That’s right. See also nixpkgs-hammering/missing-phase-hooks.md at 6a4f88d82ab7d0a95cf21494896bce40f7a4ac22 · jtojnar/nixpkgs-hammering · GitHub

1 Like

Nice writeup. That’s pretty much what I was wondering. I am overriding a postInstall hook and it turns out that it is not being called in the original package.