While running nix-shell without a shell.nix file the following warning pops up:
$ nix-shell -p glibcLocales
bash: warning: setlocale: LC_TIME: cannot change locale (en_GB.UTF-8): No such file or directory
[nix-shell:~]$
If found a couple of posts which speak about setting the environment variable LOCALE_ARCHIVE_2_27 to some path. How do I set such an environment variable automatically to the correct path? Would it help to use some shell.nix file?
Edit: My locales are set as follows:
$ cat /etc/locale.conf
LANG="en_US.UTF-8"
LC_PAPER="de_DE.UTF-8"
LC_TIME="en_GB.UTF-8"
If I remove LC_TIME="en_GB.UTF-8" from /etc/locale.conf, then the warning does not show up, even if LC_TIME="en_GB.UTF-8" nix-shell -p glibcLocales is used.
Using nix-2.3.6 on Fedora 32
$ nix-channel --list
nixpkgs https://nixos.org/channels/nixpkgs-unstable
You can populate $LOCALE_ARCHIVE_2_27 with valid path in shell.nix like this:
❯ cat shell.nix
with import <nixpkgs> {};
mkShell {
LOCALE_ARCHIVE_2_27 = "${glibcLocales}/lib/locale/locale-archive";
buildInputs = [
hello
];
}
❯ nix-shell
[nix-shell:~]$ echo $LOCALE_ARCHIVE_2_27
/nix/store/r24xc904amrdwfrzyijxmylxnxmwacm9-glibc-locales-2.31/lib/locale/locale-archive
Or pass expression as an argument
❯ nix-shell -E 'with import <nixpkgs> { }; runCommand "dummy" { LOCALE_ARCHIVE_2_27 = "${glibcLocales}/lib/locale/locale-archive"; buildInputs = [ hello ]; } ""'
[nix-shell:~]$ echo $LOCALE_ARCHIVE_2_27
/nix/store/r24xc904amrdwfrzyijxmylxnxmwacm9-glibc-locales-2.31/lib/locale/locale-archive
More details here https://gist.github.com/peti/2c818d6cb49b0b0f2fd7c300f8386bc3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With