i18n: set the appropriate LOCALE_ARCHIVE_x_xx variable (#1659)
This commit is contained in:
parent
08fc1586c0
commit
9a12cd7e81
2
.github/CODEOWNERS
vendored
2
.github/CODEOWNERS
vendored
|
@ -11,6 +11,8 @@
|
|||
|
||||
/modules/misc/gtk.nix @rycee
|
||||
|
||||
/modules/config/i18n.nix @midchildan
|
||||
|
||||
/modules/misc/news.nix @rycee
|
||||
|
||||
/modules/misc/numlock.nix @evanjs
|
||||
|
|
44
modules/config/i18n.nix
Normal file
44
modules/config/i18n.nix
Normal file
|
@ -0,0 +1,44 @@
|
|||
# The glibc package in nixpkgs is patched to make it possbile 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
|
||||
#
|
||||
# XXX: 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
|
||||
inherit (pkgs.glibcLocales) version;
|
||||
|
||||
archivePath = "${pkgs.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 {
|
||||
config = {
|
||||
# for shell sessions
|
||||
home.sessionVariables = localeVars;
|
||||
|
||||
# for desktop apps
|
||||
systemd.user.sessionVariables = localeVars;
|
||||
};
|
||||
|
||||
meta.maintainers = with maintainers; [ midchildan ];
|
||||
}
|
|
@ -22,6 +22,7 @@ let
|
|||
|
||||
allModules = [
|
||||
(loadModule ./accounts/email.nix { })
|
||||
(loadModule ./config/i18n.nix { condition = hostPlatform.isLinux; })
|
||||
(loadModule ./files.nix { })
|
||||
(loadModule ./home-environment.nix { })
|
||||
(loadModule ./manual.nix { })
|
||||
|
|
|
@ -32,10 +32,7 @@ in {
|
|||
dataDirs = concatStringsSep ":"
|
||||
(map (profile: "${profile}/share") profiles
|
||||
++ config.targets.genericLinux.extraXdgDataDirs);
|
||||
in {
|
||||
XDG_DATA_DIRS = "${dataDirs}\${XDG_DATA_DIRS:+:}$XDG_DATA_DIRS";
|
||||
LOCALE_ARCHIVE_2_27 = "${pkgs.glibcLocales}/lib/locale/locale-archive";
|
||||
};
|
||||
in { XDG_DATA_DIRS = "${dataDirs}\${XDG_DATA_DIRS:+:}$XDG_DATA_DIRS"; };
|
||||
|
||||
home.sessionVariablesExtra = ''
|
||||
. "${pkgs.nix}/etc/profile.d/nix.sh"
|
||||
|
|
|
@ -79,6 +79,7 @@ import nmt {
|
|||
] ++ lib.optionals pkgs.stdenv.hostPlatform.isDarwin [
|
||||
./modules/targets-darwin
|
||||
] ++ lib.optionals pkgs.stdenv.hostPlatform.isLinux [
|
||||
./modules/config/i18n
|
||||
./modules/misc/debug
|
||||
./modules/misc/numlock
|
||||
./modules/misc/pam
|
||||
|
|
17
tests/modules/config/i18n/default.nix
Normal file
17
tests/modules/config/i18n/default.nix
Normal file
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
i18n = { ... }: {
|
||||
config = {
|
||||
nmt.script = ''
|
||||
hmEnvFile=home-path/etc/profile.d/hm-session-vars.sh
|
||||
assertFileExists $hmEnvFile
|
||||
assertFileRegex $hmEnvFile \
|
||||
'^export LOCALE_ARCHIVE_._..=".*/lib/locale/locale-archive"$'
|
||||
|
||||
envFile=home-files/.config/environment.d/10-home-manager.conf
|
||||
assertFileExists $envFile
|
||||
assertFileRegex $envFile \
|
||||
'^LOCALE_ARCHIVE_._..=.*/lib/locale/locale-archive$'
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
{
|
||||
let inherit (pkgs.stdenv.hostPlatform) isLinux;
|
||||
in {
|
||||
imports = [
|
||||
({ ... }: { config.home.sessionPath = [ "foo" ]; })
|
||||
({ ... }: { config.home.sessionPath = [ "bar" "baz" ]; })
|
||||
|
@ -15,7 +16,9 @@
|
|||
# Only source this once.
|
||||
if [ -n "$__HM_SESS_VARS_SOURCED" ]; then return; fi
|
||||
export __HM_SESS_VARS_SOURCED=1
|
||||
${lib.optionalString isLinux ''
|
||||
|
||||
export LOCALE_ARCHIVE_2_27="${pkgs.glibcLocales}/lib/locale/locale-archive"''}
|
||||
export XDG_CACHE_HOME="/home/hm-user/.cache"
|
||||
export XDG_CONFIG_HOME="/home/hm-user/.config"
|
||||
export XDG_DATA_HOME="/home/hm-user/.local/share"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Only source this once.
|
||||
if [ -n "$__HM_SESS_VARS_SOURCED" ]; then return; fi
|
||||
export __HM_SESS_VARS_SOURCED=1
|
||||
|
||||
@exportLocaleVar@
|
||||
export V1="v1"
|
||||
export V2="v2-v1"
|
||||
export XDG_CACHE_HOME="/home/hm-user/.cache"
|
||||
|
|
|
@ -1,8 +1,18 @@
|
|||
{ config, lib, ... }:
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
let
|
||||
inherit (pkgs.stdenv.hostPlatform) isLinux;
|
||||
|
||||
expectedConf = pkgs.substituteAll {
|
||||
src = ./session-variables-expected.txt;
|
||||
# the blank space below is intentional
|
||||
exportLocaleVar = optionalString isLinux ''
|
||||
|
||||
export LOCALE_ARCHIVE_2_27="${pkgs.glibcLocales}/lib/locale/locale-archive"'';
|
||||
};
|
||||
in {
|
||||
config = {
|
||||
home.sessionVariables = {
|
||||
V1 = "v1";
|
||||
|
@ -11,9 +21,8 @@ with lib;
|
|||
|
||||
nmt.script = ''
|
||||
assertFileExists home-path/etc/profile.d/hm-session-vars.sh
|
||||
assertFileContent \
|
||||
home-path/etc/profile.d/hm-session-vars.sh \
|
||||
${./session-variables-expected.txt}
|
||||
assertFileContent home-path/etc/profile.d/hm-session-vars.sh \
|
||||
${expectedConf}
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
LOCALE_ARCHIVE_2_27=@glibcLocales@/lib/locale/locale-archive
|
||||
V_int=1
|
||||
V_str=2
|
||||
|
|
|
@ -2,7 +2,12 @@
|
|||
|
||||
with lib;
|
||||
|
||||
{
|
||||
let
|
||||
expectedConf = pkgs.substituteAll {
|
||||
src = ./session-variables-expected.conf;
|
||||
inherit (pkgs) glibcLocales;
|
||||
};
|
||||
in {
|
||||
config = {
|
||||
systemd.user.sessionVariables = {
|
||||
V_int = 1;
|
||||
|
@ -12,7 +17,7 @@ with lib;
|
|||
nmt.script = ''
|
||||
envFile=home-files/.config/environment.d/10-home-manager.conf
|
||||
assertFileExists $envFile
|
||||
assertFileContent $envFile ${./session-variables-expected.conf}
|
||||
assertFileContent $envFile ${expectedConf}
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
@ -17,9 +17,6 @@ with lib;
|
|||
assertFileContains \
|
||||
home-path/etc/profile.d/hm-session-vars.sh \
|
||||
'. "${pkgs.nix}/etc/profile.d/nix.sh"'
|
||||
assertFileContains \
|
||||
home-path/etc/profile.d/hm-session-vars.sh \
|
||||
'export LOCALE_ARCHIVE_2_27="${pkgs.glibcLocales}/lib/locale/locale-archive"'
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue