GNU bug report logs - #73876
[PATCH 0/3] Add postgresql-libversion

Previous Next

Package: guix-patches;

Reported by: Nicolas Graves <ngraves <at> ngraves.fr>

Date: Sat, 19 Oct 2024 08:56:02 UTC

Severity: normal

Tags: patch

Full log


View this message in rfc822 format

From: Nicolas Graves <ngraves <at> ngraves.fr>
To: 73876 <at> debbugs.gnu.org
Cc: Nicolas Graves <ngraves <at> ngraves.fr>
Subject: [bug#73876] [PATCH v2 3/3] gnu: databases: Rewrite final-postgresql for postgresql-service.
Date: Sun, 20 Oct 2024 16:21:35 +0200
* gnu/services/databases.scm (final-postgresql): Rewrite using a
directory-union and rename to extend-postgresql.
---
 gnu/services/databases.scm | 31 +++++++++----------------------
 1 file changed, 9 insertions(+), 22 deletions(-)

diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm
index fa332d7978..aed0f414ab 100644
--- a/gnu/services/databases.scm
+++ b/gnu/services/databases.scm
@@ -205,26 +205,13 @@ (define (create-postgresql-account config)
                (home-directory "/var/empty")
                (shell (file-append shadow "/sbin/nologin")))))))
 
-(define (final-postgresql postgresql extension-packages)
-  (if (null? extension-packages)
-    postgresql
-    (package
-      (inherit postgresql)
-      (source #f)
-      (build-system trivial-build-system)
-      (arguments
-       `(#:modules ((guix build utils) (guix build union))
-         #:builder
-         (begin
-           (use-modules (guix build utils) (guix build union) (srfi srfi-26))
-           (union-build (assoc-ref %outputs "out")
-                        (map (lambda (input) (cdr input))
-                             %build-inputs))
-           #t)))
-      (inputs
-       `(("postgresql" ,postgresql)
-         ,@(map (lambda (extension) (list "extension" extension))
-                extension-packages))))))
+(define-public (extend-postgresql postgresql extensions)
+  (if (null? extensions)
+      postgresql
+      (let ((packages (cons* postgresql extensions)))
+        (directory-union
+         (string-join (map package-name packages) "+")
+         packages))))
 
 (define postgresql-activation
   (match-lambda
@@ -250,7 +237,7 @@ (define postgresql-activation
 
            (unless (file-exists? #$data-directory)
              (let ((initdb (string-append
-                            #$(final-postgresql postgresql
+                            #$(extend-postgresql postgresql
                                                 extension-packages)
                             "/bin/initdb"))
                    (initdb-args
@@ -297,7 +284,7 @@ (define postgresql-shepherd-service
                     ((_ mode)
                      (let ((user (getpwnam "postgres"))
                            (pg_ctl #$(file-append
-                                      (final-postgresql postgresql
+                                      (extend-postgresql postgresql
                                                         extension-packages)
                                                   "/bin/pg_ctl"))
                            (options (format #f "--config-file=~a -p ~d"
-- 
2.46.0





This bug report was last modified 238 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.