1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-05 02:39:45 +01:00
home-manager/modules/config/i18n.nix

47 lines
1.5 KiB
Nix
Raw Normal View History

2020-12-16 14:22:02 +01:00
# The glibc package in Nixpkgs is patched to make it possible to specify
# an alternative path for the locale archive through a special environment
# variable. This would allow different versions of glibc to coexist on the
# same system because each version of glibc could look up different paths
# for its locale archive should the archive format ever change in
# incompatible ways.
#
# See also:
2020-12-16 14:22:02 +01:00
# - localedef(1)
# - https://nixos.org/manual/nixpkgs/stable/#locales
# - https://github.com/NixOS/nixpkgs/issues/38991
#
2020-12-16 14:22:02 +01:00
# Note, the name of the said environment variable gets updated with each
# breaking release of the glibcLocales package. Periodically check the link
# below for changes:
# https://github.com/NixOS/nixpkgs/blob/nixpkgs-unstable/pkgs/development/libraries/glibc/nix-locale-archive.patch
{ lib, pkgs, ... }:
with lib;
let
2020-12-16 14:22:02 +01:00
inherit (pkgs.glibcLocales) version;
archivePath = "${pkgs.glibcLocales}/lib/locale/locale-archive";
# lookup the version of glibcLocales and set the appropriate environment vars
2020-12-16 14:22:02 +01:00
localeVars = if versionAtLeast version "2.27" then {
LOCALE_ARCHIVE_2_27 = archivePath;
2020-12-16 14:22:02 +01:00
} else if versionAtLeast version "2.11" then {
LOCALE_ARCHIVE_2_11 = archivePath;
} else
{ };
2020-12-16 14:22:02 +01:00
in {
2020-12-16 14:22:02 +01:00
meta.maintainers = with maintainers; [ midchildan ];
config = mkIf pkgs.stdenv.hostPlatform.isLinux {
2020-12-16 14:22:02 +01:00
# For shell sessions.
home.sessionVariables = localeVars;
2020-12-16 14:22:02 +01:00
# For desktop apps.
systemd.user.sessionVariables = localeVars;
};
}