From: Christopher Baines <mail@cbaines.net>
To: guix-devel@gnu.org
Subject: [PATCH 2/2] services: postgresql: Add locale to configuration
Date: Wed, 14 Dec 2016 08:35:49 +0000 [thread overview]
Message-ID: <20161214083549.32602-2-mail@cbaines.net> (raw)
In-Reply-To: <20161214083549.32602-1-mail@cbaines.net>
* 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
next prev parent reply other threads:[~2016-12-14 8:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Christopher Baines [this message]
2016-12-15 15:55 ` [PATCH 2/2] services: postgresql: Add locale " 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161214083549.32602-2-mail@cbaines.net \
--to=mail@cbaines.net \
--cc=guix-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).