diff --git a/home-manager/po/home-manager.pot b/home-manager/po/home-manager.pot index c74e70e64..2ca746427 100644 --- a/home-manager/po/home-manager.pot +++ b/home-manager/po/home-manager.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Home Manager\n" "Report-Msgid-Bugs-To: https://github.com/nix-community/home-manager/issues\n" -"POT-Creation-Date: 2026-01-20 21:51+0100\n" +"POT-Creation-Date: 2026-01-21 09:53+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 32c3ce6b5..bc131015d 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -847,10 +847,10 @@ in ${builtins.readFile ./lib-bash/activation-init.sh} if [[ ! -v SKIP_SANITY_CHECKS ]]; then - checkUsername ${lib.escapeShellArg config.home.username} - checkHomeDirectory ${lib.escapeShellArg config.home.homeDirectory} + checkStringEq USER "$USER" ${lib.escapeShellArg config.home.username} + checkPathEq HOME "$HOME" ${lib.escapeShellArg config.home.homeDirectory} ${lib.optionalString (config.home.uid != null) '' - checkUid ${toString config.home.uid} + checkStringEq UID "$(id -u)" ${toString config.home.uid} ''} fi diff --git a/modules/lib-bash/activation-init.sh b/modules/lib-bash/activation-init.sh index 0054be42e..b16494e25 100755 --- a/modules/lib-bash/activation-init.sh +++ b/modules/lib-bash/activation-init.sh @@ -99,33 +99,28 @@ function nixProfileRemove() { fi } -function checkUsername() { - local expectedUser="$1" +function checkStringEq() { + local name="$1" + local actual="$2" + local expected="$3" - if [[ "$USER" != "$expectedUser" ]]; then - _iError 'USER is set to "%s" but we expect "%s"' "$USER" "$expectedUser" - exit 1 - fi + if [[ "$actual" != "$expected" ]]; then + # translators: For example: HOME is "/home/foo", expected "/home/bar" + _iError '%s is "%s", expected "%s"' "$name" "$actual" "$expected" + exit 1 + fi } -function checkHomeDirectory() { - local expectedHome="$1" +function checkPathEq() { + local name="$1" + local actual="$2" + local expected="$3" - if ! [[ $HOME -ef $expectedHome ]]; then - _iError 'HOME is set to "%s" but we expect "%s"' "$HOME" "$expectedHome" - exit 1 - fi -} - -function checkUid() { - local expectedUid="$1" - local actualUid - actualUid="$(id -u)" - - if [[ "$actualUid" != "$expectedUid" ]]; then - _iError 'UID is "%s" but we expect "%s"' "$actualUid" "$expectedUid" - exit 1 - fi + if ! [[ "$actual" -ef "$expected" ]]; then + # translators: For example: HOME is "/home/foo", expected "/home/bar" + _iError '%s is "%s", expected "%s"' "$name" "$actual" "$expected" + exit 1 + fi } # Note, the VERBOSE_ECHO variable is deprecated and should not be used inside diff --git a/modules/po/hm-modules.pot b/modules/po/hm-modules.pot index d8b5d3d11..6b264ef38 100644 --- a/modules/po/hm-modules.pot +++ b/modules/po/hm-modules.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Home Manager Modules\n" "Report-Msgid-Bugs-To: https://github.com/nix-community/home-manager/issues\n" -"POT-Creation-Date: 2026-01-20 21:51+0100\n" +"POT-Creation-Date: 2026-01-21 09:53+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -65,38 +65,32 @@ msgstr "" msgid "Could not find suitable profile directory, tried %s and %s" msgstr "" -#: modules/lib-bash/activation-init.sh:106 -msgid "USER is set to \"%s\" but we expect \"%s\"" +#. translators: For example: HOME is "/home/foo", expected "/home/bar" +#: modules/lib-bash/activation-init.sh:109 +#: modules/lib-bash/activation-init.sh:121 +msgid "%s is \"%s\", expected \"%s\"" msgstr "" -#: modules/lib-bash/activation-init.sh:115 -msgid "HOME is set to \"%s\" but we expect \"%s\"" -msgstr "" - -#: modules/lib-bash/activation-init.sh:126 -msgid "UID is \"%s\" but we expect \"%s\"" -msgstr "" - -#: modules/lib-bash/activation-init.sh:143 +#: modules/lib-bash/activation-init.sh:138 msgid "Starting Home Manager activation" msgstr "" -#: modules/lib-bash/activation-init.sh:147 +#: modules/lib-bash/activation-init.sh:142 msgid "Sanity checking Nix" msgstr "" -#: modules/lib-bash/activation-init.sh:160 +#: modules/lib-bash/activation-init.sh:155 msgid "This is a dry run" msgstr "" -#: modules/lib-bash/activation-init.sh:164 +#: modules/lib-bash/activation-init.sh:159 msgid "This is a live run" msgstr "" -#: modules/lib-bash/activation-init.sh:170 +#: modules/lib-bash/activation-init.sh:165 msgid "Using Nix version: %s" msgstr "" -#: modules/lib-bash/activation-init.sh:173 +#: modules/lib-bash/activation-init.sh:168 msgid "Activation variables:" msgstr "" diff --git a/tests/modules/home-environment/uid-null.nix b/tests/modules/home-environment/uid-null.nix index 6f1b915c9..e7dae767f 100644 --- a/tests/modules/home-environment/uid-null.nix +++ b/tests/modules/home-environment/uid-null.nix @@ -2,6 +2,6 @@ # home.uid defaults to null, so checkUid should not be called in the activation script nmt.script = '' - assertFileNotRegex activate "checkUid [0-9]+" + assertFileNotRegex activate "checkStringEq UID" ''; } diff --git a/tests/modules/home-environment/uid.nix b/tests/modules/home-environment/uid.nix index 06093971c..54c2111aa 100644 --- a/tests/modules/home-environment/uid.nix +++ b/tests/modules/home-environment/uid.nix @@ -2,6 +2,6 @@ home.uid = 1000; nmt.script = '' - assertFileContains activate "checkUid 1000" + assertFileContains activate 'checkStringEq UID "$(id -u)" 1000' ''; }