1
0
mirror of https://github.com/nix-community/home-manager synced 2024-07-07 05:43:27 +02:00
home-manager/modules/config/i18n.nix
Emily 36a53d9f26 treewide: convert all option docs to Markdown
This process was automated by [my fork of `nix-doc-munge`]. All
conversions were automatically checked to produce the same DocBook
result when converted back, modulo minor typographical/formatting
differences on the acceptable-to-desirable spectrum.

To reproduce this commit, run:

  $ NIX_PATH=nixpkgs=flake:nixpkgs/e7e69199f0372364a6106a1e735f68604f4c5a25 \
    nix shell nixpkgs#coreutils \
    -c find . -name '*.nix' \
    -exec nix run -- github:emilazy/nix-doc-munge/98dadf1f77351c2ba5dcb709a2a171d655f15099 \
    {} +
  $ ./format

[my fork of `nix-doc-munge`]: https://github.com/emilazy/nix-doc-munge/tree/home-manager
2023-07-17 18:40:56 +01:00

73 lines
2.2 KiB
Nix

# 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:
# - localedef(1)
# - https://nixos.org/manual/nixpkgs/stable/#locales
# - https://github.com/NixOS/nixpkgs/issues/38991
#
# 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, config, ... }:
with lib;
let
inherit (config.i18n) glibcLocales;
inherit (glibcLocales) version;
archivePath = "${glibcLocales}/lib/locale/locale-archive";
# lookup the version of glibcLocales and set the appropriate environment vars
localeVars = if versionAtLeast version "2.27" then {
LOCALE_ARCHIVE_2_27 = archivePath;
} else if versionAtLeast version "2.11" then {
LOCALE_ARCHIVE_2_11 = archivePath;
} else
{ };
in {
meta.maintainers = with maintainers; [ midchildan ];
options = {
i18n.glibcLocales = mkOption {
type = types.path;
description = lib.mdDoc ''
Customized `glibcLocales` package providing
the `LOCALE_ARCHIVE_*` environment variable.
This option only applies to the Linux platform.
When Home Manager is configured with NixOS, the default value
will be set to {var}`i18n.glibcLocales` from the
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";
};
};
config = mkIf pkgs.stdenv.hostPlatform.isLinux {
# For shell sessions.
home.sessionVariables = localeVars;
# For desktop apps.
systemd.user.sessionVariables = localeVars;
};
}