fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Robert HelgessonMerge PR #421575790441

master
2.2 KiB72 linesraw
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
23  inherit (config.i18n) glibcLocales;
24
25  inherit (glibcLocales) version;
26
27  archivePath = "${glibcLocales}/lib/locale/locale-archive";
28
29  # lookup the version of glibcLocales and set the appropriate environment vars
30  localeVars = if versionAtLeast version "2.27" then {
31    LOCALE_ARCHIVE_2_27 = archivePath;
32  } else if versionAtLeast version "2.11" then {
33    LOCALE_ARCHIVE_2_11 = archivePath;
34  } else
35    { };
36
37in {
38  meta.maintainers = with maintainers; [ midchildan ];
39
40  options = {
41    i18n.glibcLocales = mkOption {
42      type = types.path;
43      description = ''
44        Customized `glibcLocales` package providing
45        the `LOCALE_ARCHIVE_*` environment variable.
46
47        This option only applies to the Linux platform.
48
49        When Home Manager is configured with NixOS, the default value
50        will be set to {var}`i18n.glibcLocales` from the
51        system configuration.
52      '';
53      example = literalExpression ''
54        pkgs.glibcLocales.override {
55          allLocales = false;
56          locales = [ "en_US.UTF-8/UTF-8" ];
57        }
58      '';
59      # NB. See nixos/default.nix for NixOS default.
60      default = pkgs.glibcLocales;
61      defaultText = literalExpression "pkgs.glibcLocales";
62    };
63  };
64
65  config = mkIf pkgs.stdenv.hostPlatform.isLinux {
66    # For shell sessions.
67    home.sessionVariables = localeVars;
68
69    # For desktop apps.
70    systemd.user.sessionVariables = localeVars;
71  };
72}