fork/home-manager
git clone https://git.julia.blue/fork/home-manager
75790441
master
1# The glibc package in Nixpkgs is patched to make it possible to specify 2# an alternative path for the locale archive through a special environment 3# variable. This would allow different versions of glibc to coexist on the 4# same system because each version of glibc could look up different paths 5# for its locale archive should the archive format ever change in 6# incompatible ways. 7# 8# See also: 9# - localedef(1) 10# - https://nixos.org/manual/nixpkgs/stable/#locales 11# - https://github.com/NixOS/nixpkgs/issues/38991 12# 13# Note, the name of the said environment variable gets updated with each 14# breaking release of the glibcLocales package. Periodically check the link 15# below for changes: 16# https://github.com/NixOS/nixpkgs/blob/nixpkgs-unstable/pkgs/development/libraries/glibc/nix-locale-archive.patch 17 18{ lib , pkgs , config , ...} : 19 20with lib ; 21 22let 23inherit ( config . i18n ) glibcLocales ; 24 25inherit ( glibcLocales ) version ; 26 27archivePath = " ${ glibcLocales } /lib/locale/locale-archive" ; 28 29# lookup the version of glibcLocales and set the appropriate environment vars 30localeVars = if versionAtLeast version "2.27" then { 31LOCALE_ARCHIVE_2_27 = archivePath ; 32} else if versionAtLeast version "2.11" then { 33LOCALE_ARCHIVE_2_11 = archivePath ; 34} else 35{ }; 36 37in { 38meta . maintainers = with maintainers ; [ midchildan ]; 39 40options = { 41i18n . glibcLocales = mkOption { 42type = types . path ; 43description = '' 44Customized `glibcLocales` package providing 45the `LOCALE_ARCHIVE_*` environment variable. 46 47This option only applies to the Linux platform. 48 49When Home Manager is configured with NixOS, the default value 50will be set to {var}`i18n.glibcLocales` from the 51system configuration. 52'' ; 53example = literalExpression '' 54pkgs.glibcLocales.override { 55allLocales = false; 56locales = [ "en_US.UTF-8/UTF-8" ]; 57} 58'' ; 59# NB. See nixos/default.nix for NixOS default. 60default = pkgs . glibcLocales ; 61defaultText = literalExpression "pkgs.glibcLocales" ; 62}; 63}; 64 65config = mkIf pkgs . stdenv . hostPlatform . isLinux { 66# For shell sessions. 67home . sessionVariables = localeVars ; 68 69# For desktop apps. 70systemd . user . sessionVariables = localeVars ; 71}; 72}