Subject: [PATCH v3 23/24] gnu: Add ghc-9.6

From: Nicolas Graves <[email-masked]>
Date: Thu, 31 Oct 2024 13:47:02 +0100

From: Saku Laesvuori <[email-masked]>

* gnu/packages/haskell.scm (ghc-9.6): New variable.

Change-Id: I6883ed973bdd1d6eaf981605c1bc8f855f850187
---
 gnu/packages/haskell.scm | 108 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 107 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/haskell.scm b/gnu/packages/haskell.scm
index 256fe84c89..239871cfcd 100644
--- a/gnu/packages/haskell.scm
+++ b/gnu/packages/haskell.scm
@@ -72,7 +72,8 @@ (define-module (gnu packages haskell)
   #:use-module (guix packages)
   #:use-module (guix utils)
   #:use-module (ice-9 match)
-  #:use-module (ice-9 regex))
+  #:use-module (ice-9 regex)
+  #:use-module (srfi srfi-26))
 
 (define-public cl-yale-haskell
   (let ((commit "85f94c72a16c5f70301dd8db04cde9de2d7dd270")
@@ -2161,4 +2162,109 @@ (define hadrian-for-ghc-9.6
 It is based on the Shake library and replaces @{make} in building GHC")
     (license license:expat)))
 
+(define-public ghc-9.6
+  (let ((base ghc-9.4))
+    (package
+      (inherit base)
+      (name "ghc-next")
+      (version "9.6.4")
+      (source (origin
+                (inherit (package-source base))
+                (uri (string-append "https://www.haskell.org/ghc/dist/" version
+                                    "/ghc-" version "-src.tar.xz"))
+                (sha256
+                 (base32
+                  "1h6lpx8kd4xycjwb8iv2rgnz23kwq5b0qp4bhvczsx3in2w2bgqh"))))
+      (arguments
+       (substitute-keyword-arguments (package-arguments base)
+        ((#:make-flags flags ''())
+         #~(list "-V" "--docs=no-sphinx"))
+        ((#:phases phases '%standard-phases)
+         #~(let* ((run-hadrian (lambda args
+                                 (apply invoke "hadrian" args))))
+             (modify-phases #$phases
+            (delete 'fix-shell-wrappers)
+            ;; https://gitlab.haskell.org/ghc/ghc/-/issues/22557
+            (add-before 'build 'fix-iserv-rpath
+              (lambda _
+                (mkdir-p "_build")
+                (call-with-output-file
+                 "_build/hadrian.settings"
+                 (lambda (port)
+                   (display
+                    (string-append
+                     "*.iserv.ghc.link.opts += -optl-Wl,-rpath,"
+                     #$output "/lib/ghc-" #$(package-version this-package)
+                     "/lib/" #$(or (%current-target-system)
+                                   (%current-system))
+                     "-ghc-" #$(package-version this-package) "/")
+                    port)))))
+            (replace 'build
+              (lambda* (#:key (parallel-build? #f) (make-flags '())
+                        #:allow-other-keys)
+                (apply run-hadrian
+                       `("binary-dist-dir"
+                         ,@(if parallel-build?
+                             `(,(string-append "-j" (number->string (parallel-job-count))))
+                             '())
+                         ,@make-flags))))
+            (replace 'check
+              (lambda* (#:key (tests? #t) (parallel-tests? #f) (make-flags '()) #:allow-other-keys)
+                (if tests?
+                  (apply run-hadrian
+                         `(,@(if parallel-tests?
+                               `(,(string-append "-j" (number->string (parallel-job-count))))
+                               '())
+                           ,@make-flags
+                           "test"
+                           "--skip-perf"))
+                  (format #t "test suite not run~%"))))
+            (replace 'install
+              (lambda* (#:key (make-flags '()) #:allow-other-keys)
+                (apply run-hadrian
+                       `("install"
+                         ,@make-flags
+                         ,(string-append "--prefix=" #$output)))))
+            (add-after 'install 'replace-$pkgroot
+              (lambda _
+                (substitute*
+                  (find-files
+                   (string-append #$output "/lib/ghc-"
+                                  #$(package-version this-package)
+                                  "/lib/package.conf.d/")
+                   "^.*\\.conf$")
+                  (("\\$\\{pkgroot\\}/")
+                   (string-append #$output "/lib/ghc-"
+                                  #$(package-version this-package)
+                                  "/lib/"))))))))))
+      (inputs (list bash-minimal gmp ncurses libffi))
+      (native-inputs
+       `(("perl" ,perl)
+         ("python" ,python)
+         ("git" ,git-minimal/pinned)
+         ("which" ,which)
+         ("ghostscript" ,ghostscript)
+         ("autoconf" ,autoconf)
+         ("automake" ,automake)
+
+         ("hadrian" ,hadrian-for-ghc-9.6)
+         ("ghc-bootstrap" ,ghc-bootstrap-for-9.6)
+         ("ghc-alex" ,ghc-alex-bootstrap-for-9.4)
+         ("ghc-happy" ,ghc-happy-bootstrap-for-9.4)
+         ("ghc-testsuite"
+          ,(origin
+             (method url-fetch)
+             (uri (string-append
+                   "https://www.haskell.org/ghc/dist/"
+                   version "/ghc-" version "-testsuite.tar.xz"))
+             (sha256
+              (base32
+               "0wwd6d68aia2rmlpki30azz0raf98is472cqljhbzzdzpqpjh4vf"))))))
+      (native-search-paths
+       (list (search-path-specification
+              (variable "GHC_PACKAGE_PATH")
+              (files (list (string-append "lib/ghc-" version)))
+              (file-pattern ".*\\.conf\\.d$")
+              (file-type 'directory)))))))
+
 ;;; haskell.scm ends here
-- 
2.46.0