2020-12-16 13:22:02 +00:00
|
|
|
# The glibc package in Nixpkgs is patched to make it possible to specify
|
2021-01-23 14:56:38 +00:00
|
|
|
# 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 13:22:02 +00:00
|
|
|
# - localedef(1)
|
|
|
|
# - https://nixos.org/manual/nixpkgs/stable/#locales
|
|
|
|
# - https://github.com/NixOS/nixpkgs/issues/38991
|
2021-01-23 14:56:38 +00:00
|
|
|
#
|
2020-12-16 13:22:02 +00:00
|
|
|
# Note, the name of the said environment variable gets updated with each
|
2021-01-23 14:56:38 +00:00
|
|
|
# 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
|
|
|
|
|
2023-07-04 09:28:25 +00:00
|
|
|
{ lib, pkgs, config, ... }:
|
2021-01-23 14:56:38 +00:00
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
2023-07-04 09:28:25 +00:00
|
|
|
inherit (config.i18n) glibcLocales;
|
2020-12-16 13:22:02 +00:00
|
|
|
|
2023-07-04 09:28:25 +00:00
|
|
|
inherit (glibcLocales) version;
|
2021-01-23 14:56:38 +00:00
|
|
|
|
2023-07-04 09:28:25 +00:00
|
|
|
archivePath = "${glibcLocales}/lib/locale/locale-archive";
|
2021-01-23 14:56:38 +00:00
|
|
|
|
|
|
|
# lookup the version of glibcLocales and set the appropriate environment vars
|
2020-12-16 13:22:02 +00:00
|
|
|
localeVars = if versionAtLeast version "2.27" then {
|
2021-01-23 14:56:38 +00:00
|
|
|
LOCALE_ARCHIVE_2_27 = archivePath;
|
2020-12-16 13:22:02 +00:00
|
|
|
} else if versionAtLeast version "2.11" then {
|
2021-01-23 14:56:38 +00:00
|
|
|
LOCALE_ARCHIVE_2_11 = archivePath;
|
|
|
|
} else
|
|
|
|
{ };
|
2020-12-16 13:22:02 +00:00
|
|
|
|
2021-01-23 14:56:38 +00:00
|
|
|
in {
|
2020-12-16 13:22:02 +00:00
|
|
|
meta.maintainers = with maintainers; [ midchildan ];
|
|
|
|
|
2023-07-04 09:28:25 +00:00
|
|
|
options = {
|
|
|
|
i18n.glibcLocales = mkOption {
|
|
|
|
type = types.path;
|
2023-07-01 23:45:18 +00:00
|
|
|
description = ''
|
2023-06-30 23:30:13 +00:00
|
|
|
Customized `glibcLocales` package providing
|
|
|
|
the `LOCALE_ARCHIVE_*` environment variable.
|
|
|
|
|
2023-07-04 09:28:25 +00:00
|
|
|
This option only applies to the Linux platform.
|
2023-06-30 23:30:13 +00:00
|
|
|
|
2023-07-04 09:28:25 +00:00
|
|
|
When Home Manager is configured with NixOS, the default value
|
2023-06-30 23:30:13 +00:00
|
|
|
will be set to {var}`i18n.glibcLocales` from the
|
2023-07-04 09:28:25 +00:00
|
|
|
system configuration.
|
|
|
|
'';
|
|
|
|
example = literalExpression ''
|
|
|
|
pkgs.glibcLocales.override {
|
|
|
|
allLocales = false;
|
|
|
|
locales = [ "en_US.UTF-8/UTF-8" ];
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
# NB. See nixos/default.nix for NixOS default.
|
|
|
|
default = pkgs.glibcLocales;
|
|
|
|
defaultText = literalExpression "pkgs.glibcLocales";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-12-03 05:30:34 +00:00
|
|
|
config = mkIf pkgs.stdenv.hostPlatform.isLinux {
|
2020-12-16 13:22:02 +00:00
|
|
|
# For shell sessions.
|
2021-01-23 14:56:38 +00:00
|
|
|
home.sessionVariables = localeVars;
|
|
|
|
|
2020-12-16 13:22:02 +00:00
|
|
|
# For desktop apps.
|
2021-01-23 14:56:38 +00:00
|
|
|
systemd.user.sessionVariables = localeVars;
|
|
|
|
};
|
|
|
|
}
|