How to correct set LC_ALL and LANGUAGE

I add to /etc/nixos/configuration.nix

i18n.defaultLocale = “en_us.UTF-8”;

but after

nixos-rebuild switch --upgrade

I got:

activating the configuration…
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = “”,
LC_ALL = (unset),
LANG = “en_us.UTF-8”
are supported and installed on your system.
perl: warning: Falling back to the standard locale (“C”).

3 Likes

Cannot give you nix specific answer but LC_ALL overrides locale variables and the proper way is to set individual locale variables (sometimes in bulk using the single option you mentioned). LC_ALL should be unset for regular use

2 Likes

I had this problem earlier and it was because I had glibc in system path which seems to conflict with something. Relevant post: Conflict between glibc and glibcLocales? (TL;DR I messed it up) - #6 by peterhoeg

I don’t understand how to fix this error.
I add

i18n.glibcLocales = lib.hiPrio (pkgs.buildPackages.glibcLocales.override {
  allLocales = lib.any (x: x == "all") config.i18n.supportedLocales;
  locales = config.i18n.supportedLocales;
});

and got error:

undefined variable 'lib' at /etc/nixos/configuration.nix:48:23
(use '--show-trace' to show detailed location information)
building Nix...
error: undefined variable 'lib' at /etc/nixos/configuration.nix:48:23
(use '--show-trace' to show detailed location information)
building the system configuration...
error: undefined variable 'lib' at /etc/nixos/configuration.nix:48:23
(use '--show-trace' to show detailed location information)

Firstly, though it was implicit, what I really needed was not have glibc.out in systemPackages.

To fix the error you got, add lib to the first line so that it looks something like { config, pkgs, lib, ... }:

thanks, adding lib corrected the previous error.
but LC_ALL and LANGUAGE still not set

Okay I guess that wasn’t it

it is “en_US”, not “en_us”.