From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christopher Baines Subject: [PATCH 2/2] services: postgresql: Add locale to configuration Date: Sun, 11 Dec 2016 21:13:01 +0000 Message-ID: <20161211211301.28403-2-mail@cbaines.net> References: <20161211211301.28403-1-mail@cbaines.net> Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35893) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cGBQi-0005NJ-KK for guix-devel@gnu.org; Sun, 11 Dec 2016 16:13:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cGBQf-0007DP-Hc for guix-devel@gnu.org; Sun, 11 Dec 2016 16:13:08 -0500 Received: from mira.cbaines.net ([2a01:7e00::f03c:91ff:fe69:8da9]:37480) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cGBQf-0007BH-9g for guix-devel@gnu.org; Sun, 11 Dec 2016 16:13:05 -0500 Received: from localhost (88-104-161-202.dynamic.dsl.as9105.com [88.104.161.202]) by mira.cbaines.net (Postfix) with ESMTPSA id 3B46713E1BA for ; Sun, 11 Dec 2016 21:13:02 +0000 (GMT) Received: from chris by localhost with local (Exim 4.88) (envelope-from ) id 1cGBQb-0007Oo-RL for guix-devel@gnu.org; Sun, 11 Dec 2016 21:13:01 +0000 In-Reply-To: <20161211211301.28403-1-mail@cbaines.net> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: guix-devel@gnu.org * gnu/services/postgresql.scm (): 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 port config-file data-directory) + (($ 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 port config-file data-directory) + (($ 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