1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2024-12-15 17:50:53 +00:00

i18n: various fixes

This commit is contained in:
midchildan 2020-12-16 22:22:02 +09:00 committed by Robert Helgesson
parent 6f7074d21d
commit e44faef21c
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
5 changed files with 54 additions and 50 deletions

1
.github/CODEOWNERS vendored
View file

@ -12,6 +12,7 @@
/modules/misc/gtk.nix @rycee
/modules/config/i18n.nix @midchildan
/tests/modules/config/i18n @midchildan
/modules/misc/news.nix @rycee

View file

@ -1,4 +1,4 @@
# The glibc package in nixpkgs is patched to make it possbile to specify
# 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
@ -6,11 +6,11 @@
# incompatible ways.
#
# See also:
# localedef(1)
# https://nixos.org/manual/nixpkgs/stable/#locales
# https://github.com/NixOS/nixpkgs/issues/38991
# - 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
# 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
@ -20,25 +20,27 @@
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 {
localeVars = if versionAtLeast version "2.27" then {
LOCALE_ARCHIVE_2_27 = archivePath;
} else if (versionAtLeast version "2.11") then {
} else if versionAtLeast version "2.11" then {
LOCALE_ARCHIVE_2_11 = archivePath;
} else
{ };
in {
meta.maintainers = with maintainers; [ midchildan ];
config = {
# for shell sessions
# For shell sessions.
home.sessionVariables = localeVars;
# for desktop apps
# For desktop apps.
systemd.user.sessionVariables = localeVars;
};
meta.maintainers = with maintainers; [ midchildan ];
}

View file

@ -1,30 +1,15 @@
{ config, lib, pkgs, ... }:
let inherit (pkgs.stdenv.hostPlatform) isLinux;
in {
{
imports = [
({ ... }: { config.home.sessionPath = [ "foo" ]; })
({ ... }: { config.home.sessionPath = [ "bar" "baz" ]; })
];
nmt.script = ''
assertFileExists home-path/etc/profile.d/hm-session-vars.sh
assertFileContent \
home-path/etc/profile.d/hm-session-vars.sh \
${
pkgs.writeText "session-path-expected.txt" ''
# 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"
export PATH="$PATH''${PATH:+:}bar:baz:foo"
''
}
hmSessVars=home-path/etc/profile.d/hm-session-vars.sh
assertFileExists $hmSessVars
assertFileContains $hmSessVars \
'export PATH="$PATH''${PATH:+:}bar:baz:foo"'
'';
}

View file

@ -1,17 +1,36 @@
{ 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 ''
inherit (pkgs.stdenv.hostPlatform) isDarwin;
linuxExpected = ''
# Only source this once.
if [ -n "$__HM_SESS_VARS_SOURCED" ]; then return; fi
export __HM_SESS_VARS_SOURCED=1
export LOCALE_ARCHIVE_2_27="${pkgs.glibcLocales}/lib/locale/locale-archive"
export V1="v1"
export V2="v2-v1"
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"
'';
darwinExpected = ''
# Only source this once.
if [ -n "$__HM_SESS_VARS_SOURCED" ]; then return; fi
export __HM_SESS_VARS_SOURCED=1
export V1="v1"
export V2="v2-v1"
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"
'';
expected = pkgs.writeText "expected" (if isDarwin then darwinExpected else linuxExpected);
export LOCALE_ARCHIVE_2_27="${pkgs.glibcLocales}/lib/locale/locale-archive"'';
};
in {
config = {
home.sessionVariables = {
@ -22,7 +41,7 @@ in {
nmt.script = ''
assertFileExists home-path/etc/profile.d/hm-session-vars.sh
assertFileContent home-path/etc/profile.d/hm-session-vars.sh \
${expectedConf}
${expected}
'';
};
}

View file

@ -1,13 +1,6 @@
{ config, lib, pkgs, ... }:
with lib;
let
expectedConf = pkgs.substituteAll {
src = ./session-variables-expected.conf;
inherit (pkgs) glibcLocales;
};
in {
{
config = {
systemd.user.sessionVariables = {
V_int = 1;
@ -17,7 +10,11 @@ in {
nmt.script = ''
envFile=home-files/.config/environment.d/10-home-manager.conf
assertFileExists $envFile
assertFileContent $envFile ${expectedConf}
assertFileContent $envFile ${pkgs.writeText "expected" ''
LOCALE_ARCHIVE_2_27=${pkgs.glibcLocales}/lib/locale/locale-archive
V_int=1
V_str=2
''}
'';
};
}