I have some environment setup that needs to happen for a package build, and currently I do this in the
setupPhase. This is fine, but it’s confusing because when you
nix develop xx this package, some environmental setup hooks fire automatically (like the stuff for
CMAKE_PREFIX_PATH), but then there’s my in-package stuff which doesn’t happen until I explicitly
So my question is, what is that separate pre-setup setup that is happening, and how do I hook into it so that my package’s develop shell has the full environment ready to go? An example of some package already doing this would be greatly appreciated.
postHook be appropriate? Afaik those will auto-execute as you enter the shell.
You could also additionally set the
postHook worked perfectly for me, thanks for the pointer on that, @rburns.
setupHook for in-package setup? My impression was that it was more for registering setup to happen in later dependencies of the current package.
Could you clarify the difference? Is this one of these
nix shell (stuff needed for runtime) vs
nix develop (stuff needed at build time) things?
I don’t think it relates to nix shell vs nix develop, it’s more of a nix shell vs nix build thing. pre/postHook will happen when entering a shell and when building, so those hooks are for when you need to execute some arbitrary commands before the build happens. shellHook only triggers when entering a nix shell, so it would be for if you want to do some development-specific shell setup, which isn’t strictly needed to build the package.
Okay, thanks— I’m still struggling to fully grasp the difference between all these different kinds of hooks, and
mkShell, etc. I’ll maybe do a bit more experimenting on my own to try to understand it better, and then if I have remaining questions I’ll start a new thread seeking clarification.