From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christopher Baines Subject: Re: [PATCH 2/2] services: postgresql: Add locale to configuration Date: Mon, 12 Dec 2016 06:53:20 +0000 Message-ID: <8e95bcb3-15de-1176-5164-1bdbfae4698a@cbaines.net> References: <20161211211301.28403-1-mail@cbaines.net> <20161211211301.28403-2-mail@cbaines.net> <87shpuxdls.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53918) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cGKUL-00077W-F4 for guix-devel@gnu.org; Mon, 12 Dec 2016 01:53:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cGKUF-0004Iq-EB for guix-devel@gnu.org; Mon, 12 Dec 2016 01:53:29 -0500 In-Reply-To: <87shpuxdls.fsf@gnu.org> 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: =?UTF-8?Q?Ludovic_Court=c3=a8s?= Cc: guix-devel@gnu.org On 11/12/16 23:14, Ludovic Court=C3=A8s wrote: > Hi! > > Christopher Baines skribis: > >> * gnu/services/postgresql.scm (): 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 =E2=80=9Cnormalized codeset=E2=80=9D, so =E2=80= =9Cen_US.utf8=E2=80=9D. > >> (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=3D" #$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-directo= ry))) >> + (primitive-exit >> + (apply system* >> + initdb >> + "-D" >> + #$data-directory >> + initdb-args))) >> (lambda () >> (primitive-exit 1)))) >> (pid (waitpid pid)))))))) > > The effect of that is that =E2=80=98initdb=E2=80=99, but not =E2=80=98p= ostgresql=E2=80=99 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=20 database cluster", so I'd imagine that there is no problems with running=20 PostgreSQL (it seems to work for me). I think its good to support=20 setting it explicitly, but it would also be good to use the system=20 locale as a default. I thought about trying to get the LANG from /etc/environment, or the=20 , but I could not see an easy and elegant way to do=20 either. By default, initdb will use the environment, its just that the=20 environment during service activation contains no locale information.