unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH 1/2] services: postgresql: Add port to configuration
@ 2016-12-11 21:13 Christopher Baines
  2016-12-11 21:13 ` [PATCH 2/2] services: postgresql: Add locale " Christopher Baines
  2016-12-11 23:02 ` Ludovic Courtès
  0 siblings, 2 replies; 10+ messages in thread
From: Christopher Baines @ 2016-12-11 21:13 UTC (permalink / raw)
  To: guix-devel

* gnu/services/postgresql.scm (<postgresql-configuration>): Add port
  field.
  (postgresql-shepherd-service): Pass port to postgres.
  (postgresql-service): Add port default.
---
 gnu/services/databases.scm | 36 +++++++++++++++++++++---------------
 1 file changed, 21 insertions(+), 15 deletions(-)

diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm
index 1eed85542..3850ba502 100644
--- a/gnu/services/databases.scm
+++ b/gnu/services/databases.scm
@@ -48,6 +48,8 @@
   postgresql-configuration?
   (postgresql     postgresql-configuration-postgresql ;<package>
                   (default postgresql))
+  (port           postgresql-configuration-port
+                  (default 5432))
   (config-file    postgresql-configuration-file)
   (data-directory postgresql-configuration-data-directory))
 
@@ -80,7 +82,7 @@ host	all	all	::1/128 	trust"))
 
 (define postgresql-activation
   (match-lambda
-    (($ <postgresql-configuration> postgresql config-file data-directory)
+    (($ <postgresql-configuration> postgresql port config-file data-directory)
      #~(begin
          (use-modules (guix build utils)
                       (ice-9 match))
@@ -108,20 +110,22 @@ host	all	all	::1/128 	trust"))
 
 (define postgresql-shepherd-service
   (match-lambda
-    (($ <postgresql-configuration> postgresql config-file data-directory)
-     (let ((start-script
-            ;; Wrapper script that switches to the 'postgres' user before
-            ;; launching daemon.
-            (program-file "start-postgres"
-                          #~(let ((user (getpwnam "postgres"))
-                                  (postgres (string-append #$postgresql
-                                                           "/bin/postgres")))
-                              (setgid (passwd:gid user))
-                              (setuid (passwd:uid user))
-                              (system* postgres
-                                       (string-append "--config-file="
-                                                      #$config-file)
-                                       "-D" #$data-directory)))))
+    (($ <postgresql-configuration> postgresql port config-file data-directory)
+     (let* ((string-port (number->string port))
+            (start-script
+             ;; Wrapper script that switches to the 'postgres' user before
+             ;; launching daemon.
+             (program-file "start-postgres"
+                           #~(let ((user (getpwnam "postgres"))
+                                   (postgres (string-append #$postgresql
+                                                            "/bin/postgres")))
+                               (setgid (passwd:gid user))
+                               (setuid (passwd:uid user))
+                               (system* postgres
+                                        (string-append "--config-file="
+                                                       #$config-file)
+                                        "-p" #$string-port
+                                        "-D" #$data-directory)))))
        (list (shepherd-service
               (provision '(postgres))
               (documentation "Run the PostgreSQL daemon.")
@@ -140,6 +144,7 @@ host	all	all	::1/128 	trust"))
                                           (const %postgresql-accounts))))))
 
 (define* (postgresql-service #:key (postgresql postgresql)
+                             (port 5432)
                              (config-file %default-postgres-config)
                              (data-directory "/var/lib/postgresql/data"))
   "Return a service that runs @var{postgresql}, the PostgreSQL database server.
@@ -149,6 +154,7 @@ and stores the database cluster in @var{data-directory}."
   (service postgresql-service-type
            (postgresql-configuration
             (postgresql postgresql)
+            (port port)
             (config-file config-file)
             (data-directory data-directory))))
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/2] services: postgresql: Add locale to configuration
  2016-12-11 21:13 [PATCH 1/2] services: postgresql: Add port to configuration Christopher Baines
@ 2016-12-11 21:13 ` Christopher Baines
  2016-12-11 23:14   ` Ludovic Courtès
  2016-12-11 23:02 ` Ludovic Courtès
  1 sibling, 1 reply; 10+ messages in thread
From: Christopher Baines @ 2016-12-11 21:13 UTC (permalink / raw)
  To: guix-devel

* gnu/services/postgresql.scm (<postgresql-configuration>): Add locale
  field.
  (postgresql-shepherd-service): Pass locale to initdb.
  (postgresql-service): Add locale default.
---
 gnu/services/databases.scm | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm
index 3850ba502..4b97afc37 100644
--- a/gnu/services/databases.scm
+++ b/gnu/services/databases.scm
@@ -50,6 +50,8 @@
                   (default postgresql))
   (port           postgresql-configuration-port
                   (default 5432))
+  (locale         postgresql-configuration-locale
+                  (default "en_US.UTF-8"))
   (config-file    postgresql-configuration-file)
   (data-directory postgresql-configuration-data-directory))
 
@@ -82,13 +84,18 @@ host	all	all	::1/128 	trust"))
 
 (define postgresql-activation
   (match-lambda
-    (($ <postgresql-configuration> postgresql port config-file data-directory)
+    (($ <postgresql-configuration> postgresql port locale config-file data-directory)
      #~(begin
          (use-modules (guix build utils)
                       (ice-9 match))
 
          (let ((user (getpwnam "postgres"))
-               (initdb (string-append #$postgresql "/bin/initdb")))
+               (initdb (string-append #$postgresql "/bin/initdb"))
+               (initdb-args
+                (append
+                 (if #$locale
+                     (list (string-append "--locale=" #$locale))
+                     '()))))
            ;; Create db state directory.
            (mkdir-p #$data-directory)
            (chown #$data-directory (passwd:uid user) (passwd:gid user))
@@ -103,14 +110,19 @@ host	all	all	::1/128 	trust"))
                 (lambda ()
                   (setgid (passwd:gid user))
                   (setuid (passwd:uid user))
-                  (primitive-exit (system* initdb "-D" #$data-directory)))
+                  (primitive-exit
+                   (apply system*
+                          initdb
+                          "-D"
+                          #$data-directory
+                          initdb-args)))
                 (lambda ()
                   (primitive-exit 1))))
              (pid (waitpid pid))))))))
 
 (define postgresql-shepherd-service
   (match-lambda
-    (($ <postgresql-configuration> postgresql port config-file data-directory)
+    (($ <postgresql-configuration> postgresql port locale config-file data-directory)
      (let* ((string-port (number->string port))
             (start-script
              ;; Wrapper script that switches to the 'postgres' user before
@@ -145,6 +157,7 @@ host	all	all	::1/128 	trust"))
 
 (define* (postgresql-service #:key (postgresql postgresql)
                              (port 5432)
+                             (locale "en_US.UTF-8")
                              (config-file %default-postgres-config)
                              (data-directory "/var/lib/postgresql/data"))
   "Return a service that runs @var{postgresql}, the PostgreSQL database server.
@@ -155,6 +168,7 @@ and stores the database cluster in @var{data-directory}."
            (postgresql-configuration
             (postgresql postgresql)
             (port port)
+            (locale locale)
             (config-file config-file)
             (data-directory data-directory))))
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] services: postgresql: Add port to configuration
  2016-12-11 21:13 [PATCH 1/2] services: postgresql: Add port to configuration Christopher Baines
  2016-12-11 21:13 ` [PATCH 2/2] services: postgresql: Add locale " Christopher Baines
@ 2016-12-11 23:02 ` Ludovic Courtès
  1 sibling, 0 replies; 10+ messages in thread
From: Ludovic Courtès @ 2016-12-11 23:02 UTC (permalink / raw)
  To: Christopher Baines; +Cc: guix-devel

Hi!

Christopher Baines <mail@cbaines.net> skribis:

> * gnu/services/postgresql.scm (<postgresql-configuration>): Add port
>   field.
>   (postgresql-shepherd-service): Pass port to postgres.
>   (postgresql-service): Add port default.

[...]

> --- a/gnu/services/databases.scm
> +++ b/gnu/services/databases.scm
> @@ -48,6 +48,8 @@
>    postgresql-configuration?
>    (postgresql     postgresql-configuration-postgresql ;<package>
>                    (default postgresql))
> +  (port           postgresql-configuration-port
> +                  (default 5432))

Could you update guix.texi to reflect these changes?

> +    (($ <postgresql-configuration> postgresql port config-file data-directory)
> +     (let* ((string-port (number->string port))
> +            (start-script
> +             ;; Wrapper script that switches to the 'postgres' user before
> +             ;; launching daemon.
> +             (program-file "start-postgres"
> +                           #~(let ((user (getpwnam "postgres"))
> +                                   (postgres (string-append #$postgresql
> +                                                            "/bin/postgres")))
> +                               (setgid (passwd:gid user))
> +                               (setuid (passwd:uid user))
> +                               (system* postgres
> +                                        (string-append "--config-file="
> +                                                       #$config-file)
> +                                        "-p" #$string-port

I think you can omit the ‘string-port’ variable (confusing name IMO :-))
and directly write:

  "-p" #$(number->string port)

Could you send an updated patch?

Thanks!

Ludo’.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] services: postgresql: Add locale to configuration
  2016-12-11 21:13 ` [PATCH 2/2] services: postgresql: Add locale " Christopher Baines
@ 2016-12-11 23:14   ` Ludovic Courtès
  2016-12-12  6:53     ` Christopher Baines
  0 siblings, 1 reply; 10+ messages in thread
From: Ludovic Courtès @ 2016-12-11 23:14 UTC (permalink / raw)
  To: Christopher Baines; +Cc: guix-devel

Hi!

Christopher Baines <mail@cbaines.net> skribis:

> * gnu/services/postgresql.scm (<postgresql-configuration>): Add locale
>   field.
>   (postgresql-shepherd-service): Pass locale to initdb.
>   (postgresql-service): Add locale default.

[...]

> +  (locale         postgresql-configuration-locale
> +                  (default "en_US.UTF-8"))

Note: this should use the “normalized codeset”, so “en_US.utf8”.

>           (let ((user (getpwnam "postgres"))
> -               (initdb (string-append #$postgresql "/bin/initdb")))
> +               (initdb (string-append #$postgresql "/bin/initdb"))
> +               (initdb-args
> +                (append
> +                 (if #$locale
> +                     (list (string-append "--locale=" #$locale))
> +                     '()))))
>             ;; Create db state directory.
>             (mkdir-p #$data-directory)
>             (chown #$data-directory (passwd:uid user) (passwd:gid user))
> @@ -103,14 +110,19 @@ host	all	all	::1/128 	trust"))
>                  (lambda ()
>                    (setgid (passwd:gid user))
>                    (setuid (passwd:uid user))
> -                  (primitive-exit (system* initdb "-D" #$data-directory)))
> +                  (primitive-exit
> +                   (apply system*
> +                          initdb
> +                          "-D"
> +                          #$data-directory
> +                          initdb-args)))
>                  (lambda ()
>                    (primitive-exit 1))))
>               (pid (waitpid pid))))))))

The effect of that is that ‘initdb’, but not ‘postgresql’ itself, would
run in a locale different from the system locale by default.

These two inconsistencies may be quite confusing.  WDYT?

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] services: postgresql: Add locale to configuration
  2016-12-11 23:14   ` Ludovic Courtès
@ 2016-12-12  6:53     ` Christopher Baines
  2016-12-13 23:09       ` Ludovic Courtès
  0 siblings, 1 reply; 10+ messages in thread
From: Christopher Baines @ 2016-12-12  6:53 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

On 11/12/16 23:14, Ludovic Courtès wrote:
> Hi!
>
> Christopher Baines <mail@cbaines.net> skribis:
>
>> * gnu/services/postgresql.scm (<postgresql-configuration>): Add locale
>>   field.
>>   (postgresql-shepherd-service): Pass locale to initdb.
>>   (postgresql-service): Add locale default.
>
> [...]
>
>> +  (locale         postgresql-configuration-locale
>> +                  (default "en_US.UTF-8"))
>
> Note: this should use the “normalized codeset”, so “en_US.utf8”.
>
>>           (let ((user (getpwnam "postgres"))
>> -               (initdb (string-append #$postgresql "/bin/initdb")))
>> +               (initdb (string-append #$postgresql "/bin/initdb"))
>> +               (initdb-args
>> +                (append
>> +                 (if #$locale
>> +                     (list (string-append "--locale=" #$locale))
>> +                     '()))))
>>             ;; Create db state directory.
>>             (mkdir-p #$data-directory)
>>             (chown #$data-directory (passwd:uid user) (passwd:gid user))
>> @@ -103,14 +110,19 @@ host	all	all	::1/128 	trust"))
>>                  (lambda ()
>>                    (setgid (passwd:gid user))
>>                    (setuid (passwd:uid user))
>> -                  (primitive-exit (system* initdb "-D" #$data-directory)))
>> +                  (primitive-exit
>> +                   (apply system*
>> +                          initdb
>> +                          "-D"
>> +                          #$data-directory
>> +                          initdb-args)))
>>                  (lambda ()
>>                    (primitive-exit 1))))
>>               (pid (waitpid pid))))))))
>
> The effect of that is that ‘initdb’, but not ‘postgresql’ itself, would
> run in a locale different from the system locale by default.
>
> These two inconsistencies may be quite confusing.  WDYT?

I believe the locale passed to initdb sets "the default locale for the 
database cluster", so I'd imagine that there is no problems with running 
PostgreSQL (it seems to work for me). I think its good to support 
setting it explicitly, but it would also be good to use the system 
locale as a default.

I thought about trying to get the LANG from /etc/environment, or the 
<operating-system>, but I could not see an easy and elegant way to do 
either. By default, initdb will use the environment, its just that the 
environment during service activation contains no locale information.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] services: postgresql: Add locale to configuration
  2016-12-12  6:53     ` Christopher Baines
@ 2016-12-13 23:09       ` Ludovic Courtès
  2016-12-14  8:35         ` [PATCH 1/2] services: postgresql: Add port " Christopher Baines
  0 siblings, 1 reply; 10+ messages in thread
From: Ludovic Courtès @ 2016-12-13 23:09 UTC (permalink / raw)
  To: Christopher Baines; +Cc: guix-devel

Christopher Baines <mail@cbaines.net> skribis:

> On 11/12/16 23:14, Ludovic Courtès wrote:
>> Hi!
>>
>> Christopher Baines <mail@cbaines.net> skribis:
>>
>>> * gnu/services/postgresql.scm (<postgresql-configuration>): Add locale
>>>   field.
>>>   (postgresql-shepherd-service): Pass locale to initdb.
>>>   (postgresql-service): Add locale default.
>>
>> [...]
>>
>>> +  (locale         postgresql-configuration-locale
>>> +                  (default "en_US.UTF-8"))
>>
>> Note: this should use the “normalized codeset”, so “en_US.utf8”.
>>
>>>           (let ((user (getpwnam "postgres"))
>>> -               (initdb (string-append #$postgresql "/bin/initdb")))
>>> +               (initdb (string-append #$postgresql "/bin/initdb"))
>>> +               (initdb-args
>>> +                (append
>>> +                 (if #$locale
>>> +                     (list (string-append "--locale=" #$locale))
>>> +                     '()))))
>>>             ;; Create db state directory.
>>>             (mkdir-p #$data-directory)
>>>             (chown #$data-directory (passwd:uid user) (passwd:gid user))
>>> @@ -103,14 +110,19 @@ host	all	all	::1/128 	trust"))
>>>                  (lambda ()
>>>                    (setgid (passwd:gid user))
>>>                    (setuid (passwd:uid user))
>>> -                  (primitive-exit (system* initdb "-D" #$data-directory)))
>>> +                  (primitive-exit
>>> +                   (apply system*
>>> +                          initdb
>>> +                          "-D"
>>> +                          #$data-directory
>>> +                          initdb-args)))
>>>                  (lambda ()
>>>                    (primitive-exit 1))))
>>>               (pid (waitpid pid))))))))
>>
>> The effect of that is that ‘initdb’, but not ‘postgresql’ itself, would
>> run in a locale different from the system locale by default.
>>
>> These two inconsistencies may be quite confusing.  WDYT?
>
> I believe the locale passed to initdb sets "the default locale for the
> database cluster",

Oh, so it affects the initial format of the DB, right?  In that case,
you’re right of course.

> I thought about trying to get the LANG from /etc/environment, or the
> <operating-system>, but I could not see an easy and elegant way to do
> either. By default, initdb will use the environment, its just that the
> environment during service activation contains no locale information.

With 97bb1ab66519736afbdab57c230c3a9deef2fa05 there *is* locale data
available at least, right?

But yeah, there’s no easy way to retrieve the currently-configured system
locale, so let’s forget about it (maybe add an “XXX” comment next to
it.)

Could you send an updated patch with (1) the normalized codeset by
default (“en_US.utf8”), and (2) a guix.texi update mentioning the new
option?

Thanks in advance!

Ludo’.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/2] services: postgresql: Add port to configuration
  2016-12-13 23:09       ` Ludovic Courtès
@ 2016-12-14  8:35         ` Christopher Baines
  2016-12-14  8:35           ` [PATCH 2/2] services: postgresql: Add locale " Christopher Baines
  2016-12-15 15:54           ` [PATCH 1/2] services: postgresql: Add port " Ludovic Courtès
  0 siblings, 2 replies; 10+ messages in thread
From: Christopher Baines @ 2016-12-14  8:35 UTC (permalink / raw)
  To: guix-devel

* gnu/services/databases.scm (<postgresql-configuration>): Add port
  field.
  (postgresql-shepherd-service): Pass port to postgres.
  (postgresql-service): Add port default.
---
 doc/guix.texi              | 7 ++++---
 gnu/services/databases.scm | 9 +++++++--
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index f1c5963f7..af5869314 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -10150,13 +10150,14 @@ Users need to be in the @code{lp} group to access the D-Bus service.
 The @code{(gnu services databases)} module provides the following services.
 
 @deffn {Scheme Procedure} postgresql-service [#:postgresql postgresql] @
-       [#:config-file] [#:data-directory ``/var/lib/postgresql/data'']
+       [#:config-file] [#:data-directory ``/var/lib/postgresql/data''] @
+       [#:port 5432]
 Return a service that runs @var{postgresql}, the PostgreSQL database
 server.
 
 The PostgreSQL daemon loads its runtime configuration from
-@var{config-file} and stores the database cluster in
-@var{data-directory}.
+@var{config-file}, stores the database cluster in @var{data-directory} and
+listens on @var{port}.
 @end deffn
 
 @deffn {Scheme Procedure} mysql-service [#:config (mysql-configuration)]
diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm
index f7e08e696..7cdcfc4d7 100644
--- a/gnu/services/databases.scm
+++ b/gnu/services/databases.scm
@@ -48,6 +48,8 @@
   postgresql-configuration?
   (postgresql     postgresql-configuration-postgresql ;<package>
                   (default postgresql))
+  (port           postgresql-configuration-port
+                  (default 5432))
   (config-file    postgresql-configuration-file)
   (data-directory postgresql-configuration-data-directory))
 
@@ -80,7 +82,7 @@ host	all	all	::1/128 	trust"))
 
 (define postgresql-activation
   (match-lambda
-    (($ <postgresql-configuration> postgresql config-file data-directory)
+    (($ <postgresql-configuration> postgresql port config-file data-directory)
      #~(begin
          (use-modules (guix build utils)
                       (ice-9 match))
@@ -108,7 +110,7 @@ host	all	all	::1/128 	trust"))
 
 (define postgresql-shepherd-service
   (match-lambda
-    (($ <postgresql-configuration> postgresql config-file data-directory)
+    (($ <postgresql-configuration> postgresql port config-file data-directory)
      (let ((start-script
             ;; Wrapper script that switches to the 'postgres' user before
             ;; launching daemon.
@@ -121,6 +123,7 @@ host	all	all	::1/128 	trust"))
                               (system* postgres
                                        (string-append "--config-file="
                                                       #$config-file)
+                                       "-p" (number->string #$port)
                                        "-D" #$data-directory)))))
        (list (shepherd-service
               (provision '(postgres))
@@ -140,6 +143,7 @@ host	all	all	::1/128 	trust"))
                                           (const %postgresql-accounts))))))
 
 (define* (postgresql-service #:key (postgresql postgresql)
+                             (port 5432)
                              (config-file %default-postgres-config)
                              (data-directory "/var/lib/postgresql/data"))
   "Return a service that runs @var{postgresql}, the PostgreSQL database server.
@@ -149,6 +153,7 @@ and stores the database cluster in @var{data-directory}."
   (service postgresql-service-type
            (postgresql-configuration
             (postgresql postgresql)
+            (port port)
             (config-file config-file)
             (data-directory data-directory))))
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/2] services: postgresql: Add locale to configuration
  2016-12-14  8:35         ` [PATCH 1/2] services: postgresql: Add port " Christopher Baines
@ 2016-12-14  8:35           ` Christopher Baines
  2016-12-15 15:55             ` Ludovic Courtès
  2016-12-15 15:54           ` [PATCH 1/2] services: postgresql: Add port " Ludovic Courtès
  1 sibling, 1 reply; 10+ messages in thread
From: Christopher Baines @ 2016-12-14  8:35 UTC (permalink / raw)
  To: guix-devel

* gnu/services/databases.scm (<postgresql-configuration>): Add locale
  field.
  (postgresql-shepherd-service): Pass locale to initdb.
  (postgresql-service): Add locale default.
---
 doc/guix.texi              |  8 ++++----
 gnu/services/databases.scm | 22 ++++++++++++++++++----
 2 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index af5869314..46f95035d 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -10151,13 +10151,13 @@ The @code{(gnu services databases)} module provides the following services.
 
 @deffn {Scheme Procedure} postgresql-service [#:postgresql postgresql] @
        [#:config-file] [#:data-directory ``/var/lib/postgresql/data''] @
-       [#:port 5432]
+       [#:port 5432] [#:locale ``en_US.utf8'']
 Return a service that runs @var{postgresql}, the PostgreSQL database
 server.
 
-The PostgreSQL daemon loads its runtime configuration from
-@var{config-file}, stores the database cluster in @var{data-directory} and
-listens on @var{port}.
+The PostgreSQL daemon loads its runtime configuration from @var{config-file},
+creates a database cluster with @var{locale} as the default
+locale, stored in @var{data-directory}.  It then listens on @var{port}.
 @end deffn
 
 @deffn {Scheme Procedure} mysql-service [#:config (mysql-configuration)]
diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm
index 7cdcfc4d7..d88c839f7 100644
--- a/gnu/services/databases.scm
+++ b/gnu/services/databases.scm
@@ -50,6 +50,8 @@
                   (default postgresql))
   (port           postgresql-configuration-port
                   (default 5432))
+  (locale         postgresql-configuration-locale
+                  (default "en_US.utf8"))
   (config-file    postgresql-configuration-file)
   (data-directory postgresql-configuration-data-directory))
 
@@ -82,13 +84,18 @@ host	all	all	::1/128 	trust"))
 
 (define postgresql-activation
   (match-lambda
-    (($ <postgresql-configuration> postgresql port config-file data-directory)
+    (($ <postgresql-configuration> postgresql port locale config-file data-directory)
      #~(begin
          (use-modules (guix build utils)
                       (ice-9 match))
 
          (let ((user (getpwnam "postgres"))
-               (initdb (string-append #$postgresql "/bin/initdb")))
+               (initdb (string-append #$postgresql "/bin/initdb"))
+               (initdb-args
+                (append
+                 (if #$locale
+                     (list (string-append "--locale=" #$locale))
+                     '()))))
            ;; Create db state directory.
            (mkdir-p #$data-directory)
            (chown #$data-directory (passwd:uid user) (passwd:gid user))
@@ -103,14 +110,19 @@ host	all	all	::1/128 	trust"))
                 (lambda ()
                   (setgid (passwd:gid user))
                   (setuid (passwd:uid user))
-                  (primitive-exit (system* initdb "-D" #$data-directory)))
+                  (primitive-exit
+                   (apply system*
+                          initdb
+                          "-D"
+                          #$data-directory
+                          initdb-args)))
                 (lambda ()
                   (primitive-exit 1))))
              (pid (waitpid pid))))))))
 
 (define postgresql-shepherd-service
   (match-lambda
-    (($ <postgresql-configuration> postgresql port config-file data-directory)
+    (($ <postgresql-configuration> postgresql port locale config-file data-directory)
      (let ((start-script
             ;; Wrapper script that switches to the 'postgres' user before
             ;; launching daemon.
@@ -144,6 +156,7 @@ host	all	all	::1/128 	trust"))
 
 (define* (postgresql-service #:key (postgresql postgresql)
                              (port 5432)
+                             (locale "en_US.utf8")
                              (config-file %default-postgres-config)
                              (data-directory "/var/lib/postgresql/data"))
   "Return a service that runs @var{postgresql}, the PostgreSQL database server.
@@ -154,6 +167,7 @@ and stores the database cluster in @var{data-directory}."
            (postgresql-configuration
             (postgresql postgresql)
             (port port)
+            (locale locale)
             (config-file config-file)
             (data-directory data-directory))))
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] services: postgresql: Add port to configuration
  2016-12-14  8:35         ` [PATCH 1/2] services: postgresql: Add port " Christopher Baines
  2016-12-14  8:35           ` [PATCH 2/2] services: postgresql: Add locale " Christopher Baines
@ 2016-12-15 15:54           ` Ludovic Courtès
  1 sibling, 0 replies; 10+ messages in thread
From: Ludovic Courtès @ 2016-12-15 15:54 UTC (permalink / raw)
  To: Christopher Baines; +Cc: guix-devel

Christopher Baines <mail@cbaines.net> skribis:

> * gnu/services/databases.scm (<postgresql-configuration>): Add port
>   field.
>   (postgresql-shepherd-service): Pass port to postgres.
>   (postgresql-service): Add port default.

Applied, thanks!

Ludo’.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] services: postgresql: Add locale to configuration
  2016-12-14  8:35           ` [PATCH 2/2] services: postgresql: Add locale " Christopher Baines
@ 2016-12-15 15:55             ` Ludovic Courtès
  0 siblings, 0 replies; 10+ messages in thread
From: Ludovic Courtès @ 2016-12-15 15:55 UTC (permalink / raw)
  To: Christopher Baines; +Cc: guix-devel

Christopher Baines <mail@cbaines.net> skribis:

> * gnu/services/databases.scm (<postgresql-configuration>): Add locale
>   field.
>   (postgresql-shepherd-service): Pass locale to initdb.
>   (postgresql-service): Add locale default.

Applied, thanks!  :-)

Ludo’.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-12-15 15:55 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-11 21:13 [PATCH 1/2] services: postgresql: Add port to configuration Christopher Baines
2016-12-11 21:13 ` [PATCH 2/2] services: postgresql: Add locale " Christopher Baines
2016-12-11 23:14   ` Ludovic Courtès
2016-12-12  6:53     ` Christopher Baines
2016-12-13 23:09       ` Ludovic Courtès
2016-12-14  8:35         ` [PATCH 1/2] services: postgresql: Add port " Christopher Baines
2016-12-14  8:35           ` [PATCH 2/2] services: postgresql: Add locale " Christopher Baines
2016-12-15 15:55             ` Ludovic Courtès
2016-12-15 15:54           ` [PATCH 1/2] services: postgresql: Add port " Ludovic Courtès
2016-12-11 23:02 ` Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).