build-system/haskell: Support parallel builds.
authorRicardo Wurmus <rekado@elephly.net>
Tue, 16 Jun 2020 20:25:48 +0000 (22:25 +0200)
committerRicardo Wurmus <rekado@elephly.net>
Wed, 12 Aug 2020 12:45:48 +0000 (14:45 +0200)
* guix/build-system/haskell.scm (haskell-build): Add keyword PARALLEL-BUILD?
and pass it on to the builder.
* guix/build/haskell-build-system.scm (build): Accept keyword PARALLEL-BUILD?
and pass the number of parallel jobs to GHC.

guix/build-system/haskell.scm
guix/build/haskell-build-system.scm

index 1ec11c7..ab93c96 100644 (file)
@@ -105,6 +105,7 @@ version REVISION."
                         (haddock-flags ''())
                         (tests? #t)
                         (test-target "test")
+                        (parallel-build? #t)
                         (configure-flags ''())
                         (phases '(@ (guix build haskell-build-system)
                                     %standard-phases))
@@ -138,6 +139,7 @@ provides a 'Setup.hs' file as its build system."
                       #:system ,system
                       #:test-target ,test-target
                       #:tests? ,tests?
+                      #:parallel-build? ,parallel-build?
                       #:haddock? ,haddock?
                       #:phases ,phases
                       #:outputs %outputs
index 91f6213..5fd0c7d 100644 (file)
@@ -121,9 +121,12 @@ and parameters ~s~%"
     (setenv "GHC_PACKAGE_PATH" ghc-path)
     #t))
 
-(define* (build #:rest empty)
+(define* (build #:key parallel-build? #:allow-other-keys)
   "Build a given Haskell package."
-  (run-setuphs "build" '()))
+  (run-setuphs "build"
+               (if parallel-build?
+                   `(,(string-append "--ghc-option=-j" (number->string (parallel-job-count))))
+                   '())))
 
 (define* (install #:rest empty)
   "Install a given Haskell package."