From a5d22cabb063c1a9c549faf63398a3b4d8d01a81 Mon Sep 17 00:00:00 2001
From: John Ericson <John.Ericson@Obsidian.Systems>
Date: Fri, 15 Sep 2023 12:43:06 -0400
Subject: [PATCH] hadrian: `need` any `configure` script we will call

When the script is changed, we should reconfigure.
---
 hadrian/src/Hadrian/Haskell/Cabal/Parse.hs | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs b/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
index 760f4295c93d..36e5d075b5c0 100644
--- a/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
+++ b/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
@@ -144,17 +144,21 @@ configurePackage context@Context {..} = do
     need deps
 
     -- Figure out what hooks we need.
+    let configureFile = replaceFileName (pkgCabalFile package) "configure"
+        -- induce dependency on the file
+        autoconfUserHooks = do
+          need [configureFile]
+          pure C.autoconfUserHooks
     hooks <- case C.buildType (C.flattenPackageDescription gpd) of
-        C.Configure -> pure C.autoconfUserHooks
+        C.Configure -> autoconfUserHooks
         C.Simple -> pure C.simpleUserHooks
         C.Make -> fail "build-type: Make is not supported"
         -- The 'time' package has a 'C.Custom' Setup.hs, but it's actually
         -- 'C.Configure' plus a @./Setup test@ hook. However, Cabal is also
         -- 'C.Custom', but doesn't have a configure script.
         C.Custom -> do
-            configureExists <- doesFileExist $
-                replaceFileName (pkgCabalFile package) "configure"
-            pure $ if configureExists then C.autoconfUserHooks else C.simpleUserHooks
+            configureExists <- doesFileExist configureFile
+            if configureExists then autoconfUserHooks else pure C.simpleUserHooks
 
     -- Compute the list of flags, and the Cabal configuration arguments
     flagList    <- interpret (target context (Cabal Flags stage) [] []) getArgs
-- 
GitLab