diff mbox series

[bug#35930,3/4] guix: haskell-build-system: generate Setup.hsif not exists

Message ID 20190527195619.59883-3-rob@vllmrt.net
State Accepted
Headers show
Series [bug#35930,1/4] gnu: ghc-easy-plot: remove superfluousSetup.hs rename step | expand

Checks

Context Check Description
cbaines/applying patch fail Apply failed

Commit Message

Robert Vollmert May 27, 2019, 7:56 p.m. UTC
The default Setup.hs is boilerplate that is frequently left out of
source packages, causing build failure for package definitions as
generated by `guix import hackage`. Compare
<https://github.com/phadej/time-compat/issues/4>

* guix/build/haskell-build-system.scm: Generate Setup.hs if missing,
after unpack phase.
---
 guix/build/haskell-build-system.scm | 12 ++++++++++++
 1 file changed, 12 insertions(+)
diff mbox series

Patch

diff --git a/guix/build/haskell-build-system.scm b/guix/build/haskell-build-system.scm
index 5c5b32322b..0c648e510f 100644
--- a/guix/build/haskell-build-system.scm
+++ b/guix/build/haskell-build-system.scm
@@ -275,9 +275,21 @@  given Haskell package."
       (_ (error "Could not find a Cabal file to patch."))))
   #t)
 
+(define* (generate-setup #:rest empty)
+  "Generate boilerplate Setup.hs if missing."
+  (when (not (or (file-exists? "Setup.hs")
+                 (file-exists? "Setup.lhs")))
+    (format #t "generating missing Setup.hs~%")
+    (with-output-to-file "Setup.hs"
+      (lambda ()
+        (format #t "import Distribution.Simple~%")
+        (format #t "main = defaultMain~%"))))
+  #t)
+
 (define %standard-phases
   (modify-phases gnu:%standard-phases
     (add-after 'unpack 'patch-cabal-file patch-cabal-file)
+    (add-after 'unpack 'generate-setup generate-setup)
     (delete 'bootstrap)
     (add-before 'configure 'setup-compiler setup-compiler)
     (add-before 'install 'haddock haddock)