Skip to content

nix, xdg/systemDirs: declare search paths as search variables - #9858

Open
khaneliman wants to merge 3 commits into
masterfrom
session-vars-1-search-vars
Open

khaneliman wants to merge 3 commits into
masterfrom
session-vars-1-search-vars

Conversation

@khaneliman

@khaneliman khaneliman commented Aug 28, 2026 •

Copy link
Copy Markdown
Collaborator

Description

NIX_PATH (under nix.nixPath with keepOldNixPath),
XDG_CONFIG_DIRS, and XDG_DATA_DIRS were defined as self-referential
home.sessionVariables values. This declares them through
home.sessionSearchVariables instead, without depending on the variable being
defined.

The shared search-variable generator now reads inherited values through a
default-safe expansion. Unset variables behave as empty under set -u, so this
PR does not depend on a later stack layer for safe shell startup. Existing
plain home.sessionSearchVariables entries retain their precedence over the
migrated module entries.

systemd.user.sessionVariables is untouched, so environment.d output is
byte-identical. One intentional compatibility change remains: a value set
through home.sessionVariables no longer collides with these module
definitions and instead becomes the trailing value. The news entry documents
list merging, lib.mkForce, exact-value migration, and the separate
environment.d behavior.

Part of splitting #9735 into independently reviewable changes; the stack as a
whole supersedes that PR.

Checklist

  • Change is backwards compatible. (User-defined values for these three
    names now compose with the module entries; a news entry is included.)
  • Code formatted with nix fmt.
  • Code tested through focused NMT suites.
  • Test cases updated and added.
  • Commit messages follow the {component}: {description} format.

@khaneliman khaneliman changed the title session vars 1 search vars nix, xdg/systemDirs: declare search paths as search variables Aug 28, 2026
@khaneliman
khaneliman force-pushed the session-vars-1-search-vars branch from 2d429dd to 4fd0020 Compare August 28, 2026 06:17
@khaneliman
khaneliman force-pushed the session-vars-1-search-vars branch 5 times, most recently from 2e47fea to 9d5f688 Compare August 29, 2026 02:55
@khaneliman
khaneliman marked this pull request as ready for review August 29, 2026 02:56
@home-manager-ci
home-manager-ci Bot requested a review from tadfisher August 29, 2026 02:57
@khaneliman
khaneliman force-pushed the session-vars-1-search-vars branch from 9d5f688 to 65d8582 Compare September 9, 2026 22:13
@khaneliman
khaneliman removed this pull request from stack #9866 September 11, 2026 03:12
@khaneliman
khaneliman changed the base branch from generic-linux-source-nix-once to master September 11, 2026 03:12
@khaneliman
khaneliman force-pushed the session-vars-1-search-vars branch from 65d8582 to ccb75bf Compare September 11, 2026 03:12
@khaneliman
khaneliman added this pull request to stack #9926 September 11, 2026 03:12
@khaneliman
khaneliman force-pushed the session-vars-1-search-vars branch 2 times, most recently from b7375cd to 7738360 Compare October 1, 2026 02:11
Read inherited search-variable values through `${VAR-}` so generated
files remain safe when sourced under `set -u`.

Preserve ordinary unset, empty, and inherited values. Add runtime
coverage and update the affected search-variable expectations.
`nix.nixPath` with `keepOldNixPath` produced a self-referential
`home.sessionVariables.NIX_PATH`. Declare it through
`home.sessionSearchVariables` instead. The generated value keeps the
same search path without depending on the variable it defines.

Order the module entries with `lib.mkAfter` so existing plain
`home.sessionSearchVariables.NIX_PATH` entries retain their precedence.
`XDG_CONFIG_DIRS` and `XDG_DATA_DIRS` were self-referential
`home.sessionVariables` values. Declare the shell side through
`home.sessionSearchVariables`, which expands to the same search path.

Order the module entries after existing plain search-variable
contributions. This preserves the previous user, module, then inherited
lookup order. `systemd.user.sessionVariables` is unchanged, so the
`environment.d` output is byte-identical.

Add a news entry covering these two names and `NIX_PATH`. A user value
set through `home.sessionVariables` now becomes the trailing value
instead of colliding with the module definition. The entry also
documents list merging, `lib.mkForce`, and the separate `environment.d`
behavior.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant