[Nix-dev] Setup hook evaluation order

Thomas Tuegel ttuegel at mailbox.org
Sun Jun 25 16:17:56 CEST 2017


On Sunday, June 25, 2017 1:31:28 AM CDT Vladimír Čunát wrote:
> On 06/22/2017 01:05 PM, Thomas Tuegel wrote:
> > How can I make my setup hook be evaluated after multiple-outputs.sh is
> > loaded?
> Immediate idea, maybe there's a better way: make the envHook just extend
> prePhases by a function that does the actual work.  That should get run
> after all envHooks but before all phases.

I think for most setup hooks your suggestion would work. Unfortunately, the setup hook I'm working with is actually a *template* for a family of setup hooks, so I can't define any functions as there is no easy way to ensure they are uniquely named.

The solution I implemented [1] is to set a postHook which reloads the setup hook by filename. The setup hook checks the hookName variable, and when it is set to postHook, runs the true body of the setup hook.

> Still, I wonder if we should change the order to run the setup hooks
> from stdenv before those from packages.  It would seem more natural.

I tend to agree. Upon examination, I found several other definitions which I thought should precede loading the setup hooks. I have made a pull request [2] to staging.

Regards,
Tom

---

[1]. https://github.com/NixOS/nixpkgs/commit/0030c6610353b3706fe77d4cce06f1905a4aec43
[2]. https://github.com/NixOS/nixpkgs/pull/26844




More information about the nix-dev mailing list