diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index f8ae353c5..3946afef5 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -12,6 +12,7 @@ /modules/misc/gtk.nix @rycee /modules/config/i18n.nix @midchildan +/tests/modules/config/i18n @midchildan /modules/misc/news.nix @rycee diff --git a/modules/config/i18n.nix b/modules/config/i18n.nix index 18eb40fc3..9fca360da 100644 --- a/modules/config/i18n.nix +++ b/modules/config/i18n.nix @@ -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 ]; } diff --git a/tests/modules/home-environment/session-path.nix b/tests/modules/home-environment/session-path.nix index 08477c5a7..57cfeceda 100644 --- a/tests/modules/home-environment/session-path.nix +++ b/tests/modules/home-environment/session-path.nix @@ -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"' ''; - } diff --git a/tests/modules/home-environment/session-variables.nix b/tests/modules/home-environment/session-variables.nix index 87c044f14..d939c05eb 100644 --- a/tests/modules/home-environment/session-variables.nix +++ b/tests/modules/home-environment/session-variables.nix @@ -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} ''; }; } diff --git a/tests/modules/systemd/session-variables.nix b/tests/modules/systemd/session-variables.nix index d00844eb0..59d1a4d3a 100644 --- a/tests/modules/systemd/session-variables.nix +++ b/tests/modules/systemd/session-variables.nix @@ -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 + ''} ''; }; }