summary refs log tree commit diff
path: root/gnu/system.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2014-11-26 22:49:11 +0100
committerLudovic Courtès <ludo@gnu.org>2014-11-27 08:55:46 +0100
commit598e19dca1677aebfe235e974f480b5bdd322694 (patch)
treea894c7f5a56ea04163ea687b01aa1c701d97d73c /gnu/system.scm
parent9b4d1e7321d04f5d0075810090e72dc16e1578ac (diff)
downloadguix-598e19dca1677aebfe235e974f480b5bdd322694.tar.gz
system: Build system-wide locale definitions.
* gnu/system/locale.scm: New file.
* gnu-system.am (GNU_SYSTEM_MODULES): Add it.
* gnu/system.scm (<operating-system>)[locale]: Change the default to
  "en_US.utf8".
  (operating-system-locale-directory): New procecure.
  (operating-system-derivation): Use it.
* doc/guix.texi (Using the Configuration System): Change example locale
  to "fr_FR.utf8".
  (operating-system Reference): Add xref to "Locales".  Document
  'locale-definitions'.
  (Locales): New section.
* po/guix/POTFILES.in: Add gnu/system.scm.
Diffstat (limited to 'gnu/system.scm')
-rw-r--r--gnu/system.scm23
1 files changed, 22 insertions, 1 deletions
diff --git a/gnu/system.scm b/gnu/system.scm
index 5c915d3969..8883d3e752 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -46,12 +46,15 @@
   #:use-module (gnu services base)
   #:use-module (gnu system grub)
   #:use-module (gnu system shadow)
+  #:use-module (gnu system locale)
   #:use-module (gnu system linux)
   #:use-module (gnu system linux-initrd)
   #:use-module (gnu system file-systems)
   #:use-module (ice-9 match)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
+  #:use-module (srfi srfi-34)
+  #:use-module (srfi srfi-35)
   #:export (operating-system
             operating-system?
 
@@ -69,6 +72,7 @@
             operating-system-packages
             operating-system-timezone
             operating-system-locale
+            operating-system-locale-definitions
             operating-system-mapped-devices
             operating-system-file-systems
             operating-system-activation-script
@@ -129,7 +133,9 @@
 
   (timezone operating-system-timezone)            ; string
   (locale   operating-system-locale               ; string
-            (default "en_US.UTF-8"))
+            (default "en_US.utf8"))
+  (locale-definitions operating-system-locale-definitions ; list of <locale-definition>
+                      (default %default-locale-definitions))
 
   (services operating-system-user-services        ; list of monadic services
             (default %base-services))
@@ -649,6 +655,19 @@ we're running in the final root."
                                            #:mapped-devices mapped-devices)))
     (return #~(string-append #$initrd "/initrd"))))
 
+(define (operating-system-locale-directory os)
+  "Return the directory containing the locales compiled for the definitions
+listed in OS.  The C library expects to find it under
+/run/current-system/locale."
+  ;; While we're at it, check whether the locale of OS is defined.
+  (unless (member (operating-system-locale os)
+                  (map locale-definition-name
+                       (operating-system-locale-definitions os)))
+    (raise (condition
+            (&message (message "system locale lacks a definition")))))
+
+  (locale-directory (operating-system-locale-definitions os)))
+
 (define (kernel->grub-label kernel)
   "Return a label for the GRUB menu entry that boots KERNEL."
   (string-append "GNU with "
@@ -698,6 +717,7 @@ this file is the reconstruction of GRUB menu entries for old configurations."
        (boot        (operating-system-boot-script os))
        (kernel  ->  (operating-system-kernel os))
        (initrd      (operating-system-initrd-file os))
+       (locale      (operating-system-locale-directory os))
        (params      (operating-system-parameters-file os)))
     (file-union "system"
                 `(("boot" ,#~#$boot)
@@ -705,6 +725,7 @@ this file is the reconstruction of GRUB menu entries for old configurations."
                   ("parameters" ,#~#$params)
                   ("initrd" ,initrd)
                   ("profile" ,#~#$profile)
+                  ("locale" ,#~#$locale)          ;used by libc
                   ("etc" ,#~#$etc)))))
 
 ;;; system.scm ends here