summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
Diffstat (limited to 'gnu')
-rw-r--r--gnu/system.scm23
-rw-r--r--gnu/system/locale.scm126
2 files changed, 148 insertions, 1 deletions
diff --git a/gnu/system.scm b/gnu/system.scm
index 5c915d39698..8883d3e752c 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -46,12 +46,15 @@
46 #:use-module (gnu services base) 46 #:use-module (gnu services base)
47 #:use-module (gnu system grub) 47 #:use-module (gnu system grub)
48 #:use-module (gnu system shadow) 48 #:use-module (gnu system shadow)
49 #:use-module (gnu system locale)
49 #:use-module (gnu system linux) 50 #:use-module (gnu system linux)
50 #:use-module (gnu system linux-initrd) 51 #:use-module (gnu system linux-initrd)
51 #:use-module (gnu system file-systems) 52 #:use-module (gnu system file-systems)
52 #:use-module (ice-9 match) 53 #:use-module (ice-9 match)
53 #:use-module (srfi srfi-1) 54 #:use-module (srfi srfi-1)
54 #:use-module (srfi srfi-26) 55 #:use-module (srfi srfi-26)
56 #:use-module (srfi srfi-34)
57 #:use-module (srfi srfi-35)
55 #:export (operating-system 58 #:export (operating-system
56 operating-system? 59 operating-system?
57 60
@@ -69,6 +72,7 @@
69 operating-system-packages 72 operating-system-packages
70 operating-system-timezone 73 operating-system-timezone
71 operating-system-locale 74 operating-system-locale
75 operating-system-locale-definitions
72 operating-system-mapped-devices 76 operating-system-mapped-devices
73 operating-system-file-systems 77 operating-system-file-systems
74 operating-system-activation-script 78 operating-system-activation-script
@@ -129,7 +133,9 @@
129 133
130 (timezone operating-system-timezone) ; string 134 (timezone operating-system-timezone) ; string
131 (locale operating-system-locale ; string 135 (locale operating-system-locale ; string
132 (default "en_US.UTF-8")) 136 (default "en_US.utf8"))
137 (locale-definitions operating-system-locale-definitions ; list of <locale-definition>
138 (default %default-locale-definitions))
133 139
134 (services operating-system-user-services ; list of monadic services 140 (services operating-system-user-services ; list of monadic services
135 (default %base-services)) 141 (default %base-services))
@@ -649,6 +655,19 @@ we're running in the final root."
649 #:mapped-devices mapped-devices))) 655 #:mapped-devices mapped-devices)))
650 (return #~(string-append #$initrd "/initrd")))) 656 (return #~(string-append #$initrd "/initrd"))))
651 657
658(define (operating-system-locale-directory os)
659 "Return the directory containing the locales compiled for the definitions
660listed in OS. The C library expects to find it under
661/run/current-system/locale."
662 ;; While we're at it, check whether the locale of OS is defined.
663 (unless (member (operating-system-locale os)
664 (map locale-definition-name
665 (operating-system-locale-definitions os)))
666 (raise (condition
667 (&message (message "system locale lacks a definition")))))
668
669 (locale-directory (operating-system-locale-definitions os)))
670
652(define (kernel->grub-label kernel) 671(define (kernel->grub-label kernel)
653 "Return a label for the GRUB menu entry that boots KERNEL." 672 "Return a label for the GRUB menu entry that boots KERNEL."
654 (string-append "GNU with " 673 (string-append "GNU with "
@@ -698,6 +717,7 @@ this file is the reconstruction of GRUB menu entries for old configurations."
698 (boot (operating-system-boot-script os)) 717 (boot (operating-system-boot-script os))
699 (kernel -> (operating-system-kernel os)) 718 (kernel -> (operating-system-kernel os))
700 (initrd (operating-system-initrd-file os)) 719 (initrd (operating-system-initrd-file os))
720 (locale (operating-system-locale-directory os))
701 (params (operating-system-parameters-file os))) 721 (params (operating-system-parameters-file os)))
702 (file-union "system" 722 (file-union "system"
703 `(("boot" ,#~#$boot) 723 `(("boot" ,#~#$boot)
@@ -705,6 +725,7 @@ this file is the reconstruction of GRUB menu entries for old configurations."
705 ("parameters" ,#~#$params) 725 ("parameters" ,#~#$params)
706 ("initrd" ,initrd) 726 ("initrd" ,initrd)
707 ("profile" ,#~#$profile) 727 ("profile" ,#~#$profile)
728 ("locale" ,#~#$locale) ;used by libc
708 ("etc" ,#~#$etc))))) 729 ("etc" ,#~#$etc)))))
709 730
710;;; system.scm ends here 731;;; system.scm ends here
diff --git a/gnu/system/locale.scm b/gnu/system/locale.scm
new file mode 100644
index 00000000000..9c5c4d2fd92
--- /dev/null
+++ b/gnu/system/locale.scm
@@ -0,0 +1,126 @@
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2014 Ludovic Courtès <ludo@gnu.org>
3;;;
4;;; This file is part of GNU Guix.
5;;;
6;;; GNU Guix is free software; you can redistribute it and/or modify it
7;;; under the terms of the GNU General Public License as published by
8;;; the Free Software Foundation; either version 3 of the License, or (at
9;;; your option) any later version.
10;;;
11;;; GNU Guix is distributed in the hope that it will be useful, but
12;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14;;; GNU General Public License for more details.
15;;;
16;;; You should have received a copy of the GNU General Public License
17;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19(define-module (gnu system locale)
20 #:use-module (guix gexp)
21 #:use-module (guix records)
22 #:use-module (gnu packages base)
23 #:use-module (gnu packages compression)
24 #:use-module (srfi srfi-26)
25 #:export (locale-definition
26 locale-definition?
27 locale-definition-name
28 locale-definition-source
29 locale-definition-charset
30
31 locale-directory
32
33 %default-locale-definitions))
34
35;;; Commentary:
36;;;
37;;; Locale definitions, and compilation thereof.
38;;;
39;;; Code:
40
41(define-record-type* <locale-definition> locale-definition
42 make-locale-definition
43 locale-definition?
44 (name locale-definition-name) ;string--e.g., "fr_FR.utf8"
45 (source locale-definition-source) ;string--e.g., "fr_FR"
46 (charset locale-definition-charset ;string--e.g., "UTF-8"
47 (default "UTF-8")))
48
49(define* (localedef-command locale
50 #:key (libc (canonical-package glibc)))
51 "Return a gexp that runs 'localdef' from LIBC to build LOCALE."
52 #~(begin
53 (format #t "building locale '~a'...~%"
54 #$(locale-definition-name locale))
55 (zero? (system* (string-append #$libc "/bin/localedef")
56 "--no-archive" "--prefix" #$output
57 "-i" #$(locale-definition-source locale)
58 "-f" #$(locale-definition-charset locale)
59 (string-append #$output "/"
60 #$(locale-definition-name locale))))))
61
62(define* (locale-directory locales
63 #:key (libc (canonical-package glibc)))
64 "Return a directory containing all of LOCALES compiled."
65 (define build
66 #~(begin
67 (mkdir #$output)
68
69 ;; 'localedef' executes 'gzip' to access compressed locale sources.
70 (setenv "PATH" (string-append #$gzip "/bin"))
71
72 (exit
73 (and #$@(map (cut localedef-command <> #:libc libc)
74 locales)))))
75
76 (gexp->derivation "locale" build
77 #:local-build? #t))
78
79(define %default-locale-definitions
80 ;; Arbitrary set of locales that are built by default. They are here mostly
81 ;; to facilitate first-time use to some people, while others may have to add
82 ;; a specific <locale-definition>.
83 (letrec-syntax ((utf8-locale (syntax-rules ()
84 ((_ name*)
85 (locale-definition
86 (name (string-append name* ".utf8"))
87 (source name*)
88 (charset "UTF-8")))))
89 (utf8-locales (syntax-rules ()
90 ((_ name ...)
91 (list (utf8-locale name) ...)))))
92 (utf8-locales "ca_ES"
93 "cs_CZ"
94 "da_DK"
95 "de_DE"
96 "el_GR"
97 "en_AU"
98 "en_CA"
99 "en_GB"
100 "en_US"
101 "es_AR"
102 "es_CL"
103 "es_ES"
104 "es_MX"
105 "fi_FI"
106 "fr_BE"
107 "fr_CA"
108 "fr_CH"
109 "fr_FR"
110 "ga_IE"
111 "it_IT"
112 "ja_JP"
113 "ko_KR"
114 "nb_NO"
115 "nl_NL"
116 "pl_PL"
117 "pt_PT"
118 "ro_RO"
119 "ru_RU"
120 "sv_SE"
121 "tr_TR"
122 "uk_UA"
123 "vi_VN"
124 "zh_CN")))
125
126;;; locale.scm ends here