Skip to content

Commit

Permalink
bump cabal-install to point to haskell/cabal#9899
Browse files Browse the repository at this point in the history
  • Loading branch information
angerman committed May 7, 2024
1 parent 74ad13a commit 26b414c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 85 deletions.
60 changes: 30 additions & 30 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 1 addition & 55 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
nix-tools.url = "github:input-output-hk/haskell.nix?dir=nix-tools";
nix-tools.flake = false;

cabal-install.url = "github:haskell/cabal?ref=Cabal-v3.10.3.0";
cabal-install.url = "github:erikd/cabal?ref=erikd/pre-post-build-hooks";
cabal-install.flake = false;

# rust stuff
Expand Down Expand Up @@ -720,60 +720,6 @@ index 3aeb0e5..bea0ac9 100644
modules = [
({ lib, config, ... }:{
packages.Cabal.patches = lib.mkForce [];
packages.cabal-install.patches = [
(builtins.toFile "cabal-install-hooks.patch" ''
--- a/src/Distribution/Client/ProjectBuilding.hs
+++ b/src/Distribution/Client/ProjectBuilding.hs
@@ -102,6 +102,7 @@
import Control.Exception (Handler (..), SomeAsyncException, assert, catches, handle)
import System.Directory (canonicalizePath, createDirectoryIfMissing, doesDirectoryExist, doesFileExist, removeFile, renameDirectory)
import System.FilePath (dropDrive, makeRelative, normalise, takeDirectory, (<.>), (</>))
+import qualified System.Process as Process
import System.IO (IOMode (AppendMode), Handle, withFile)
import Distribution.Compat.Directory (listDirectory)
@@ -989,8 +990,22 @@
-- Build phase
noticeProgress ProgressBuilding
- annotateFailure mlogFile BuildFailed $
- setup buildCommand buildFlags
+ annotateFailure mlogFile BuildFailed $ do
+ -- run preBuildHook. If it returns with 0, we assume the build was
+ -- successful. If not, run the build.
+ code <- rawSystemExitCodeX verbosity (Just srcdir) "preBuildHook" [
+ (unUnitId $ installedUnitId rpkg)
+ , srcdir
+ , builddir
+ ] `catchIO` (\_ -> return (ExitFailure 10))
+ when (code /= ExitSuccess) $ do
+ setup buildCommand buildFlags
+ -- not sure, if we want to care about a failed postBuildHook?
+ void $ rawSystemExitCodeX verbosity (Just srcdir) "postBuildHook" [
+ (unUnitId $ installedUnitId rpkg)
+ , srcdir
+ , builddir
+ ] `catchIO` (\_ -> return (ExitFailure 10))
-- Haddock phase
whenHaddock $ do
@@ -1197,6 +1212,15 @@
Just logFile -> withFile logFile AppendMode (action . Just)
+rawSystemExitCodeX :: Verbosity -> Maybe FilePath -> FilePath -> [String] -> IO ExitCode
+rawSystemExitCodeX verbosity mbWorkDir path args =
+ rawSystemProc verbosity $
+ (Process.proc path args)
+ { Process.cwd = mbWorkDir
+ }
+
+
+
hasValidHaddockTargets :: ElaboratedConfiguredPackage -> Bool
hasValidHaddockTargets ElaboratedConfiguredPackage{..}
| not elabBuildHaddocks = False
'')];
})
(pkgs.lib.mkIf pkgs.hostPlatform.isDarwin {
packages.cabal-install.components.exes.cabal.ghcOptions = with pkgs; [
Expand Down

0 comments on commit 26b414c

Please sign in to comment.