Locales: Difference between revisions

From NixOS Wiki
imported>Mjlbach
Created page with "== Troubleshooting when using nix on non-NixOS linux distributions == You may need to set the environmental variable LOCALE_ACHIVE to point to your system's locale-achive. Th..."
 
Roland (talk | contribs)
Document Locales with nix profile
 
(6 intermediate revisions by 5 users not shown)
Line 1: Line 1:
== Troubleshooting when using nix on non-NixOS linux distributions ==
== Troubleshooting when using nix on non-NixOS linux distributions ==


You may need to set the environmental variable LOCALE_ACHIVE to point to your system's locale-achive. The following applies to Debian, Red Hat, and Arch derivatives:
You may need to set the environmental variable LOCALE_ARCHIVE to point to your system's locale-archive. The following can be added to your .zshenv (zsh) or .profile (bash) and applies to Debian, Red Hat, and Arch derivatives:


<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>
export LOCALE_ARCHIVE=/usr/lib/locale/locale-archive
export LOCALE_ARCHIVE=/usr/lib/locale/locale-archive
</syntaxhighlight>
And if that file from the local system is somehow broken:
<syntaxhighlight lang="bash">
# May require a one-time installation with:
nix profile install nixpkgs#glibcLocales
# Using nix profile
export LOCALE_ARCHIVE="$(nix profile list --json | jq '.elements[] | select(.attrPath? and (.attrPath | type == "string") and (.attrPath | endswith("glibcLocales"))) | .storePaths[0]')/lib/locale/locale-archive"
# Legacy usage with `nix-env`: May require a one-time installation with: nix-env -iA nixpkgs.glibcLocales
export LOCALE_ARCHIVE="$(nix-env --installed --no-name --out-path --query glibc-locales)/lib/locale/locale-archive"
</syntaxhighlight>
== Enable locale support in Nix shell ==
To support locales within a Nix shell, for example to get localised command output, you need to do something similar:
<syntaxhighlight lang=bash>
pkgs.mkShell {
  # [other code omitted]
  LOCALE_ARCHIVE = "${pkgs.glibcLocales}/lib/locale/locale-archive";
}
</syntaxhighlight>
</syntaxhighlight>

Latest revision as of 19:10, 30 September 2024

Troubleshooting when using nix on non-NixOS linux distributions

You may need to set the environmental variable LOCALE_ARCHIVE to point to your system's locale-archive. The following can be added to your .zshenv (zsh) or .profile (bash) and applies to Debian, Red Hat, and Arch derivatives:

export LOCALE_ARCHIVE=/usr/lib/locale/locale-archive

And if that file from the local system is somehow broken:

# May require a one-time installation with:
nix profile install nixpkgs#glibcLocales
# Using nix profile
export LOCALE_ARCHIVE="$(nix profile list --json | jq '.elements[] | select(.attrPath? and (.attrPath | type == "string") and (.attrPath | endswith("glibcLocales"))) | .storePaths[0]')/lib/locale/locale-archive"

# Legacy usage with `nix-env`: May require a one-time installation with: nix-env -iA nixpkgs.glibcLocales
export LOCALE_ARCHIVE="$(nix-env --installed --no-name --out-path --query glibc-locales)/lib/locale/locale-archive"

Enable locale support in Nix shell

To support locales within a Nix shell, for example to get localised command output, you need to do something similar:

pkgs.mkShell {
  # [other code omitted]
  LOCALE_ARCHIVE = "${pkgs.glibcLocales}/lib/locale/locale-archive";
}