diff mbox series

[bug#70280,2/5] system: ‘operating-system-locale-definitions’ includes the OS’ locale.

Message ID 184c38bf07d985a8831f60024a2ae94e2fd6804d.1712585810.git.ludo@gnu.org
State New
Headers show
Series Reducing system size: locales and initrd | expand

Commit Message

Ludovic Courtès April 8, 2024, 2:24 p.m. UTC
* gnu/system.scm (<operating-system>)[locale-definitions]: Mark as
thunked.  Default to (operating-system-default-locale-definitions os).
(operating-system-default-locale-definitions): New procedure.
(operating-system-locale-directory): Remove logic to add the OS
‘locale’, instead assuming (operating-system-locale-directory os) has
everything.
* doc/guix.texi (operating-system Reference): Adjust accordingly.

Change-Id: I8798fa0de7421e0bfc07870cc3cae6b7f99fa47d
---
 doc/guix.texi  |  3 ++-
 gnu/system.scm | 28 +++++++++++++++-------------
 2 files changed, 17 insertions(+), 14 deletions(-)

Comments

pelzflorian (Florian Pelz) April 10, 2024, 9:09 a.m. UTC | #1
Hello Ludo, with a clearer mind now:

Ludovic Courtès <ludo@gnu.org> writes:
> * gnu/system.scm (<operating-system>)[locale-definitions]: Mark as
> thunked.  Default to (operating-system-default-locale-definitions os).
> (operating-system-default-locale-definitions): New procedure.
> (operating-system-locale-directory): Remove logic to add the OS
> ‘locale’, instead assuming (operating-system-locale-directory os) has
> everything.
> * doc/guix.texi (operating-system Reference): Adjust accordingly.

This is a regression.  I have in my /run/current-system/configuration.scm

 (locale "de_DE.utf8")
 (locale-definitions
  (cons* (locale-definition
          (name "ar_SY.utf8") (source "ar_SY"))
         (locale-definition
          (name "bn_BD.utf8") (source "bn_BD"))
         (locale-definition
          (name "hu_HU.utf8") (source "hu_HU"))
         (locale-definition
          (name "ka_GE.utf8") (source "ka_GE"))
         (locale-definition
          (name "lt_LT.utf8") (source "lt_LT"))
         (locale-definition
          (name "oc_FR.utf8") (source "oc_FR"))
         (locale-definition
          (name "pt_BR.utf8") (source "pt_BR"))
         (locale-definition
          (name "si_LK.utf8") (source "si_LK"))
         (locale-definition
          (name "sk_SK.utf8") (source "sk_SK"))
         (locale-definition
          (name "sr_RS.utf8") (source "sr_RS"))
         %default-locale-definitions))

but de_DE.utf8 is not available and
“export LC_ALL=de_DE.utf8” gives an error.

scheme@(guix-user)> ,use (gnu system locale)
scheme@(guix-user)> %default-locale-definitions
$1 = (#<<locale-definition> name: "ar_DZ.utf8" source: "ar_DZ" charset: "UTF-8"> #<<locale-definition> name: "ar_JO.utf8" source: "ar_JO" charset: "UTF-8"> #<<locale-definition> name: "en_GB.utf8" source: "en_GB" charset: "UTF-8"> #<<locale-definition> name: "en_US.utf8" source: "en_US" charset: "UTF-8"> #<<locale-definition> name: "es_AR.utf8" source: "es_AR" charset: "UTF-8"> #<<locale-definition> name: "es_ES.utf8" source: "es_ES" charset: "UTF-8"> #<<locale-definition> name: "fr_CA.utf8" source: "fr_CA" charset: "UTF-8"> #<<locale-definition> name: "fr_FR.utf8" source: "fr_FR" charset: "UTF-8"> #<<locale-definition> name: "ru_RU.utf8" source: "ru_RU" charset: "UTF-8"> #<<locale-definition> name: "zh_CN.utf8" source: "zh_CN" charset: "UTF-8">)

Regards,
Florian
pelzflorian (Florian Pelz) April 10, 2024, 9:52 a.m. UTC | #2
"pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de> writes:
> This is a regression.  I have in my /run/current-system/configuration.scm
>
>  (locale "de_DE.utf8")
>  (locale-definitions
>   (cons* (locale-definition
>           (name "ar_SY.utf8") (source "ar_SY"))
>          (locale-definition
>           (name "bn_BD.utf8") (source "bn_BD"))
>          (locale-definition
>           (name "hu_HU.utf8") (source "hu_HU"))
>          (locale-definition
>           (name "ka_GE.utf8") (source "ka_GE"))
>          (locale-definition
>           (name "lt_LT.utf8") (source "lt_LT"))
>          (locale-definition
>           (name "oc_FR.utf8") (source "oc_FR"))
>          (locale-definition
>           (name "pt_BR.utf8") (source "pt_BR"))
>          (locale-definition
>           (name "si_LK.utf8") (source "si_LK"))
>          (locale-definition
>           (name "sk_SK.utf8") (source "sk_SK"))
>          (locale-definition
>           (name "sr_RS.utf8") (source "sr_RS"))
>          %default-locale-definitions))
>
> but de_DE.utf8 is not available and
> “export LC_ALL=de_DE.utf8” gives an error.

I meant to also write:

scheme@(guix-user)> ,use (gnu system)
scheme@(guix-user)> (operating-system-locale-definitions (load "/run/current-system/configuration.scm"))
$2 = (#<<locale-definition> name: "ar_SY.utf8" source: "ar_SY" charset: "UTF-8"> #<<locale-definition> name: "bn_BD.utf8" source: "bn_BD" charset: "UTF-8"> #<<locale-definition> name: "hu_HU.utf8" source: "hu_HU" charset: "UTF-8"> #<<locale-definition> name: "ka_GE.utf8" source: "ka_GE" charset: "UTF-8"> #<<locale-definition> name: "lt_LT.utf8" source: "lt_LT" charset: "UTF-8"> #<<locale-definition> name: "oc_FR.utf8" source: "oc_FR" charset: "UTF-8"> #<<locale-definition> name: "pt_BR.utf8" source: "pt_BR" charset: "UTF-8"> #<<locale-definition> name: "si_LK.utf8" source: "si_LK" charset: "UTF-8"> #<<locale-definition> name: "sk_SK.utf8" source: "sk_SK" charset: "UTF-8"> #<<locale-definition> name: "sr_RS.utf8" source: "sr_RS" charset: "UTF-8"> #<<locale-definition> name: "ar_DZ.utf8" source: "ar_DZ" charset: "UTF-8"> #<<locale-definition> name: "ar_JO.utf8" source: "ar_JO" charset: "UTF-8"> #<<locale-definition> name: "en_GB.utf8" source: "en_GB" charset: "UTF-8"> #<<locale-definition> name: "en_US.utf8" source: "en_US" charset: "UTF-8"> #<<locale-definition> name: "es_AR.utf8" source: "es_AR" charset: "UTF-8"> #<<locale-definition> name: "es_ES.utf8" source: "es_ES" charset: "UTF-8"> #<<locale-definition> name: "fr_CA.utf8" source: "fr_CA" charset: "UTF-8"> #<<locale-definition> name: "fr_FR.utf8" source: "fr_FR" charset: "UTF-8"> #<<locale-definition> name: "ru_RU.utf8" source: "ru_RU" charset: "UTF-8"> #<<locale-definition> name: "zh_CN.utf8" source: "zh_CN" charset: "UTF-8">)

No de_DE in there, but it should be.

Regards,
Florian
Ludovic Courtès April 15, 2024, 4:23 p.m. UTC | #3
"pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de> skribis:

> Ludovic Courtès <ludo@gnu.org> writes:
>> * gnu/system.scm (<operating-system>)[locale-definitions]: Mark as
>> thunked.  Default to (operating-system-default-locale-definitions os).
>> (operating-system-default-locale-definitions): New procedure.
>> (operating-system-locale-directory): Remove logic to add the OS
>> ‘locale’, instead assuming (operating-system-locale-directory os) has
>> everything.
>> * doc/guix.texi (operating-system Reference): Adjust accordingly.
>
> This is a regression.  I have in my /run/current-system/configuration.scm
>
>  (locale "de_DE.utf8")
>  (locale-definitions
>   (cons* (locale-definition
>           (name "ar_SY.utf8") (source "ar_SY"))
>          (locale-definition
>           (name "bn_BD.utf8") (source "bn_BD"))
>          (locale-definition
>           (name "hu_HU.utf8") (source "hu_HU"))
>          (locale-definition
>           (name "ka_GE.utf8") (source "ka_GE"))
>          (locale-definition
>           (name "lt_LT.utf8") (source "lt_LT"))
>          (locale-definition
>           (name "oc_FR.utf8") (source "oc_FR"))
>          (locale-definition
>           (name "pt_BR.utf8") (source "pt_BR"))
>          (locale-definition
>           (name "si_LK.utf8") (source "si_LK"))
>          (locale-definition
>           (name "sk_SK.utf8") (source "sk_SK"))
>          (locale-definition
>           (name "sr_RS.utf8") (source "sr_RS"))
>          %default-locale-definitions))
>
> but de_DE.utf8 is not available and
> “export LC_ALL=de_DE.utf8” gives an error.

Right.

I would call it a semantic change rather than a regression (a feature
rather than a bug :-)).

It’s more in line with what we’re doing elsewhere: the default is to
include ‘locale’ in the locale definitions, but we let the user override
that if they wish.

Perhaps we should at least clarify the manual?

Ludo’.
pelzflorian (Florian Pelz) April 15, 2024, 10:51 p.m. UTC | #4
Ludovic Courtès <ludo@gnu.org> writes:
> "pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de> skribis:
>> This is a regression.  I have in my /run/current-system/configuration.scm
>>
>>  (locale "de_DE.utf8")
>>  (locale-definitions
>>   (cons* (locale-definition
>>           (name "ar_SY.utf8") (source "ar_SY"))
>>          (locale-definition
>>           (name "bn_BD.utf8") (source "bn_BD"))
>>          (locale-definition
>>           (name "hu_HU.utf8") (source "hu_HU"))
>>          (locale-definition
>>           (name "ka_GE.utf8") (source "ka_GE"))
>>          (locale-definition
>>           (name "lt_LT.utf8") (source "lt_LT"))
>>          (locale-definition
>>           (name "oc_FR.utf8") (source "oc_FR"))
>>          (locale-definition
>>           (name "pt_BR.utf8") (source "pt_BR"))
>>          (locale-definition
>>           (name "si_LK.utf8") (source "si_LK"))
>>          (locale-definition
>>           (name "sk_SK.utf8") (source "sk_SK"))
>>          (locale-definition
>>           (name "sr_RS.utf8") (source "sr_RS"))
>>          %default-locale-definitions))
>>
>> but de_DE.utf8 is not available and
>> “export LC_ALL=de_DE.utf8” gives an error.
>
> Right.
>
> I would call it a semantic change rather than a regression (a feature
> rather than a bug :-)).
>
> It’s more in line with what we’re doing elsewhere: the default is to
> include ‘locale’ in the locale definitions, but we let the user override
> that if they wish.


It is a regression when with the same OS config.scm, my GNOME is no
longer in German.  Perhaps I’m missing something, but the only gain from
making it configurable to not include the configured default locale in
locale-definitions would be that it becomes possible to not include the
default locale language’s utf8 encoding, but utf8 is good for everyone.

> Perhaps we should at least clarify the manual?
>
> Ludo’.

I would have expected the prior behavior, i.e. the setting in locale to
be available regardless of locale-definitions.  To me it does not seem
necessary to be documented explicitly, but maybe better be explicit.

Regards,
Florian
Ludovic Courtès April 17, 2024, 3:16 p.m. UTC | #5
"pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de> skribis:

> Ludovic Courtès <ludo@gnu.org> writes:

[...]

>> I would call it a semantic change rather than a regression (a feature
>> rather than a bug :-)).
>>
>> It’s more in line with what we’re doing elsewhere: the default is to
>> include ‘locale’ in the locale definitions, but we let the user override
>> that if they wish.
>
>
> It is a regression when with the same OS config.scm, my GNOME is no
> longer in German.  Perhaps I’m missing something, but the only gain from
> making it configurable to not include the configured default locale in
> locale-definitions would be that it becomes possible to not include the
> default locale language’s utf8 encoding, but utf8 is good for everyone.

OK, let’s drop this patch then.

I was focusing on interface consistency but in this particular case what
you describe suggests interface consistency is a secondary concern.

Thanks,
Ludo’.
diff mbox series

Patch

diff --git a/doc/guix.texi b/doc/guix.texi
index 5827e0de14..7ca06046ba 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -17502,7 +17502,8 @@  operating-system Reference
 The name of the default locale (@pxref{Locale Names,,, libc, The GNU C
 Library Reference Manual}).  @xref{Locales}, for more information.
 
-@item @code{locale-definitions} (default: @code{%default-locale-definitions})
+@item @code{locale-definitions} (default: @
+  @code{(operating-system-default-locale-definitions os)})
 The list of locale definitions to be compiled and that may be used at
 run time.  @xref{Locales}.
 
diff --git a/gnu/system.scm b/gnu/system.scm
index aef81d8ccf..94d734b014 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -282,7 +282,9 @@  (define-record-type* <operating-system> operating-system
   (locale   operating-system-locale               ; string
             (default "en_US.utf8"))
   (locale-definitions operating-system-locale-definitions ; list of <locale-definition>
-                      (default %default-locale-definitions))
+                      (thunked)
+                      (default (operating-system-default-locale-definitions
+                                this-operating-system)))
   (locale-libcs operating-system-locale-libcs     ; list of <packages>
                 (default %default-locale-libcs))
   (name-service-switch operating-system-name-service-switch ; <name-service-switch>
@@ -1397,22 +1399,22 @@  (define (locale-name->definition* name)
      (raise (formatted-message (G_ "~a: invalid locale name") name)))
     (def def)))
 
+(define (operating-system-default-locale-definitions os)
+  "Return the default locale definitions for OS, which includes that specified
+in its 'locale' field."
+  (define name
+    (operating-system-locale os))
+
+  (if (member name (map locale-definition-name %default-locale-definitions))
+      %default-locale-definitions
+      (cons (locale-name->definition* name)
+            %default-locale-definitions)))
+
 (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."
-  (define name
-    (operating-system-locale os))
-
-  (define definitions
-    ;; While we're at it, check whether NAME is defined and add it if needed.
-    (if (member name (map locale-definition-name
-                          (operating-system-locale-definitions os)))
-        (operating-system-locale-definitions os)
-        (cons (locale-name->definition* name)
-              (operating-system-locale-definitions os))))
-
-  (locale-directory definitions
+  (locale-directory (operating-system-locale-definitions os)
                     #:libcs (operating-system-locale-libcs os)))
 
 (define* (kernel->boot-label kernel #:key hurd)