You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
shell hooks for augmenting how cabal-install does various actions? #7394
with example application for example being: and then you could hook into phases of like pre_configure and invoke ghcup automatically, installing the requested project ghc version
at the moment, i think cabal's pre/post-$FOO (for some value of FOO) hooks are only supported as haskell function call backs, which hits a different point in the ease of scripting tradeoffs
Potential "hooks" that added behavior to those functions (shell invocations, logging, and so on) could be defined as functions RunProjectPreBuildPhase -> RunProjectPreBuildPhase or FreezeAction -> FreezeAction, respectively. And they could be applied to the original functions here, in the so-called "composition context". If the hooks needed to allocate some resources of their own, it could also be done there.
There's no need of course for all the fancy inversion of control used in this example: cabal-install hook management could be integrated in the runProjectPreBuildPhase function itself, although perhaps that would complicate its code a little.
One thing to consider is what subset of the configuration information available at the pre-build phase should be passed to the script—and in what manner. Passing everything as script parameters might not be a good idea if we pass a lot of things, many of them optional. Perhaps we could write values to the script's stdin?
One thing to consider is what subset of the configuration information available at the pre-build phase should be passed to the script—and in what manner. Passing everything as script parameters might not be a good idea if we pass a lot of things, many of them optional. Perhaps we could write values to the script's stdin?
changed the title [-]shell hooks for augmenting how cabal does various actions?[/-][+]shell hooks for augmenting how cabal-install does various actions?[/+]on Jun 17, 2021
Activity
cartazio commentedon May 12, 2021
there may already be a tracking ticket related to this, but i'm not super familiar with older tickets ;)
cartazio commentedon May 12, 2021
loosely related is #3600
danidiaz commentedon Jun 12, 2021
One possible way of supporting hooks is by extending the experimental branch described here.
In that branch, functions like runProjectPreBuildPhase and freezeAction have been wrapped in newtypes.
Potential "hooks" that added behavior to those functions (shell invocations, logging, and so on) could be defined as functions
RunProjectPreBuildPhase -> RunProjectPreBuildPhaseorFreezeAction -> FreezeAction, respectively. And they could be applied to the original functions here, in the so-called "composition context". If the hooks needed to allocate some resources of their own, it could also be done there.fgaz commentedon Jun 13, 2021
This is for
cabal-installhooks, right?cartazio commentedon Jun 13, 2021
I believe yes :)
danidiaz commentedon Jun 15, 2021
A proof-of-concept of how cabal-install script hooks could work is here.
In the cabal project we wish to compile, the following folder structure should exist:
cabal-install ignores the hooks by default; hook handling is enabled through an environment variable, like this:
The
before_pre_build.shscript is passed the value of the followingcabal.projectsetting as an argument:An example of
before_pre_build.shthat calls ghcup:The hook-handling code is in
Distribution.Client.Instrumentation.Hooks.There's no need of course for all the fancy inversion of control used in this example: cabal-install hook management could be integrated in the
runProjectPreBuildPhasefunction itself, although perhaps that would complicate its code a little.One thing to consider is what subset of the configuration information available at the pre-build phase should be passed to the script—and in what manner. Passing everything as script parameters might not be a good idea if we pass a lot of things, many of them optional. Perhaps we could write values to the script's stdin?
fgaz commentedon Jun 17, 2021
what about environment variables?
[-]shell hooks for augmenting how cabal does various actions?[/-][+]shell hooks for augmenting how cabal-install does various actions?[/+]NorfairKing commentedon Apr 23, 2023
What's the status of the implementation of issue?