Discussion:
Setup hook evaluation order
(too old to reply)
Thomas Tuegel
2017-06-22 11:05:27 UTC
Permalink
Hi nix-dev,

My package has a setup hook which needs $outputDev, $outputLib, etc. to be
set. In other words, I need the multiple-outputs.sh setup hook to be loaded
before my setup hook is evaluated. However, multiple-outputs.sh is part of
defaultNativeBuildInputs and is always loaded *after* any packages in
buildInputs or nativeBuildInputs.

How can I make my setup hook be evaluated after multiple-outputs.sh is loaded?

Thanks,
Tom
Vladimír Čunát
2017-06-25 06:31:28 UTC
Permalink
Post by Thomas Tuegel
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.

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.

--Vladimir
Thomas Tuegel
2017-06-25 14:17:56 UTC
Permalink
Post by Vladimír Čunát
Post by Thomas Tuegel
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.
Post by Vladimír Čunát
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

Loading...