build-system/haskell: Generate Setup.hs if needed.

The default Setup.hs is boilerplate that is frequently left out of
source packages.  Several packages already add a phase to generate it,
so moving this phase to the build system is just factoring out an
existing pattern.

See <https://github.com/phadej/time-compat/issues/4>.

* guix/build/haskell-build-system.scm (generate-setuphs): New procedure.
(%standard-phases): Add it after 'unpack'.
* gnu/packages/haskell.scm (ghc-foundation, ghc-inline-c,
ghc-inline-c-cpp, ghc-rio): Remove 'arguments'.

Signed-off-by: Timothy Sample <samplet@ngyro.com>
This commit is contained in:
Robert Vollmert 2019-05-27 21:56:18 +02:00 committed by Timothy Sample
parent 5f9f2c82e6
commit ed8d3f33a5
No known key found for this signature in database
GPG key ID: 2AC6A5EC1C357C59
2 changed files with 12 additions and 42 deletions

View file

@ -275,9 +275,21 @@ given Haskell package."
(_ (error "Could not find a Cabal file to patch."))))
#t)
(define* (generate-setuphs #:rest empty)
"Generate a default Setup.hs if needed."
(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-setuphs generate-setuphs)
(delete 'bootstrap)
(add-before 'configure 'setup-compiler setup-compiler)
(add-before 'install 'haddock haddock)