Subject: [PATCH v2 1/4] gnu: grass: Improve package style.

From: Vinicius Monego <[email-masked]>
Date: Mon, 31 Mar 2025 01:49:43 +0000

* gnu/packages/geo.scm (grass)[arguments]: Use Gexp.
<#:phases>: Use #:configure-flags instead of overriding the 'configure
phase.

Change-Id: I52b39f0cd5ad507dfe5dbb5c8040dfe4eb69b18c
---
 gnu/packages/geo.scm | 127 +++++++++++++++++++++----------------------
 1 file changed, 62 insertions(+), 65 deletions(-)

diff --git a/gnu/packages/geo.scm b/gnu/packages/geo.scm
index 8682d29e0e..cdab9ac608 100644
--- a/gnu/packages/geo.scm
+++ b/gnu/packages/geo.scm
@@ -3261,74 +3261,71 @@ (define-public grass
              flex
              pkg-config))
       (arguments
-       `(#:tests? #f                    ; No tests
-         #:modules ((guix build gnu-build-system)
+       (list
+        #:tests? #f                    ; No tests
+        #:modules `((guix build gnu-build-system)
                     ((guix build python-build-system) #:prefix python:)
                     (guix build utils))
-         #:imported-modules (,@%default-gnu-imported-modules
+        #:imported-modules `(,@%default-gnu-imported-modules
                              (guix build python-build-system))
-         #:phases
-         (modify-phases %standard-phases
-           (add-after 'unpack 'fix-lapack
-             (lambda _
-               (substitute* "./configure"
-                 (("-lblas") "-lopenblas")
-                 (("-llapack") "-lopenblas"))))
-           (replace 'configure
-             (lambda* (#:key inputs outputs #:allow-other-keys)
-               (let ((shell (search-input-file inputs "/bin/bash")))
-                 (setenv "SHELL" shell)
-                 (setenv "CONFIG_SHELL" shell)
-                 (setenv "LDFLAGS" (string-append "-Wl,-rpath -Wl,"
-                                                  (assoc-ref outputs "out")
-                                                  "/" ,grassxx "/lib")))
-               (invoke "./configure"
-                       (string-append "--prefix="
-                                      (assoc-ref outputs "out"))
-                       "--with-blas"
-                       "--with-bzlib"
-                       (string-append
-                        "--with-freetype-includes="
-                        (search-input-directory inputs "/include/freetype2"))
-                       (string-append
-                        "--with-freetype-libs="
-                        (dirname
-                         (search-input-file inputs "/lib/libfreetype.so")))
-                       "--with-geos"
-                       "--with-lapack"
-                       "--with-mysql"
-                       (string-append
-                        "--with-mysql-includes="
-                        (search-input-directory inputs "/include/mysql"))
-                       (string-append
-                        "--with-mysql-libs="
-                        (dirname
-                         (search-input-file inputs "/lib/libmariadb.so")))
-                       "--with-netcdf"
-                       "--with-postgres"
-                       (string-append
-                        "--with-proj-share="
-                        (search-input-directory inputs "/share/proj"))
-                       "--with-pthread"
-                       "--with-readline"
-                       "--with-sqlite"
-                       "--with-wxwidgets")))
-           (add-after 'install 'install-links
-             (lambda* (#:key outputs #:allow-other-keys)
-               ;; Put links for includes and libraries in the standard places.
-               (let* ((out (assoc-ref outputs "out"))
-                      (dir (string-append out "/" ,grassxx)))
-                 (symlink (string-append dir "/include")
-                          (string-append out "/include"))
-                 (symlink (string-append dir "/lib")
-                          (string-append out "/lib")))))
-           (add-after 'install-links 'python:wrap
-             (assoc-ref python:%standard-phases 'wrap))
-           (add-after 'python:wrap 'wrap-with-python-interpreter
-             (lambda* (#:key outputs #:allow-other-keys)
-               (let ((out (assoc-ref outputs "out")))
-                 (wrap-program (string-append out "/bin/" ,grassxx)
-                   `("GRASS_PYTHON" = (,(which "python3"))))))))))
+        #:configure-flags
+        #~(list "--with-blas"
+                "--with-bzlib"
+                (string-append
+                 "--with-freetype-includes="
+                 (search-input-directory %build-inputs "/include/freetype2"))
+                (string-append
+                 "--with-freetype-libs="
+                 (dirname
+                  (search-input-file %build-inputs "/lib/libfreetype.so")))
+                "--with-geos"
+                "--with-lapack"
+                "--with-mysql"
+                (string-append
+                 "--with-mysql-includes="
+                 (search-input-directory %build-inputs "/include/mysql"))
+                (string-append
+                 "--with-mysql-libs="
+                 (dirname
+                  (search-input-file %build-inputs "/lib/libmariadb.so")))
+                "--with-netcdf"
+                "--with-postgres"
+                (string-append
+                 "--with-proj-share="
+                 (search-input-directory %build-inputs "/share/proj"))
+                "--with-pthread"
+                "--with-readline"
+                "--with-sqlite"
+                "--with-wxwidgets"
+                (string-append
+                 "SHELL="
+                 (search-input-file %build-inputs "/bin/bash"))
+                (string-append
+                 "CONFIG_SHELL="
+                 (search-input-file %build-inputs "/bin/bash"))
+                (string-append "LDFLAGS=-Wl,-rpath -Wl,"
+                               #$output "/" #$grassxx "/lib"))
+        #:phases
+        #~(modify-phases %standard-phases
+            (add-after 'unpack 'fix-lapack
+              (lambda _
+                (substitute* "./configure"
+                  (("-lblas") "-lopenblas")
+                  (("-llapack") "-lopenblas"))))
+            (add-after 'install 'install-links
+              (lambda _
+                ;; Put links for includes and libraries in the standard places.
+                (let ((dir (string-append #$output "/" #$grassxx)))
+                  (symlink (string-append dir "/include")
+                           (string-append #$output "/include"))
+                  (symlink (string-append dir "/lib")
+                           (string-append #$output "/lib")))))
+            (add-after 'install-links 'python:wrap
+              (assoc-ref python:%standard-phases 'wrap))
+            (add-after 'python:wrap 'wrap-with-python-interpreter
+              (lambda _
+                  (wrap-program (string-append #$output "/bin/" #$grassxx)
+                    `("GRASS_PYTHON" = (,(which "python3")))))))))
       (synopsis "GRASS Geographic Information System")
       (description
        "GRASS (Geographic Resources Analysis Support System), is a Geographic

base-commit: a3674c059abf16256f549c4d558a0140b9cd8945
-- 
2.49.0