Skip to content

lib/shell: warn on self-referential session variables - #9863

Open
khaneliman wants to merge 1 commit into
session-vars-5-darwin-terminfofrom
session-vars-6-self-reference-warning
Open

khaneliman wants to merge 1 commit into
session-vars-5-darwin-terminfofrom
session-vars-6-self-reference-warning

Conversation

@khaneliman

@khaneliman khaneliman commented Aug 28, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Warns when home.sessionVariables or programs.zsh.sessionVariables contains a direct self-reference that may change when applied more than once. This PR changes diagnostics only; generated session-variable output is unchanged.

The detector follows each caller's rendering rules, including Zsh backslash escaping. It excludes stable whole-value references, default and assignment expansions, and alternate expansions whose selected value is stable. The check remains best-effort and does not try to parse indirect references.

Each offender is attributed to the surviving definition of that attribute. Attribution respects module conditions, priorities, ordering, and explicit definition locations. The warning recommends the search-variable options for path-like values and complete assignments for other variables.

This gives users advance notice before the next PR allows session-variable configuration to run in each new shell.

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

Checklist

  • Change is backwards compatible.
  • Code formatted with nix fmt.
  • Code tested through nix build .#test-all.
  • Test cases updated/added.
  • Commit messages follow the {component}: {description} format.

@github-actions github-actions Bot added the shell label Aug 28, 2026
@khaneliman khaneliman changed the title session vars 6 self reference warning lib/shell: warn on self-referential session variables Aug 28, 2026
@khaneliman
khaneliman force-pushed the session-vars-6-self-reference-warning branch from be37b8f to aaa509d Compare August 28, 2026 06:17
@khaneliman
khaneliman force-pushed the session-vars-6-self-reference-warning branch 2 times, most recently from c423753 to d1b8f95 Compare August 28, 2026 20:48
@khaneliman
khaneliman force-pushed the session-vars-6-self-reference-warning branch from d1b8f95 to db64429 Compare August 28, 2026 20:58
@khaneliman
khaneliman force-pushed the session-vars-6-self-reference-warning branch from db64429 to ba28415 Compare August 28, 2026 21:04
@khaneliman
khaneliman force-pushed the session-vars-6-self-reference-warning branch 2 times, most recently from 7af7a17 to 9c5f5ae Compare August 29, 2026 04:20
@khaneliman
khaneliman force-pushed the session-vars-6-self-reference-warning branch from 9c5f5ae to 01d3a49 Compare August 29, 2026 04:47
@khaneliman
khaneliman force-pushed the session-vars-6-self-reference-warning branch from 01d3a49 to af16441 Compare August 29, 2026 13:30
@khaneliman
khaneliman force-pushed the session-vars-6-self-reference-warning branch 2 times, most recently from 4f4bc39 to d791196 Compare August 30, 2026 03:02
@khaneliman
khaneliman force-pushed the session-vars-6-self-reference-warning branch 2 times, most recently from a62bd55 to 3f62937 Compare August 30, 2026 20:02
@khaneliman
khaneliman marked this pull request as ready for review August 30, 2026 20:04
@home-manager-ci
home-manager-ci Bot requested a review from rycee August 30, 2026 20:05
@khaneliman
khaneliman force-pushed the session-vars-6-self-reference-warning branch from 3f62937 to 527e9b9 Compare September 9, 2026 22:13
@khaneliman
khaneliman removed this pull request from stack #9866 September 11, 2026 03:12
@khaneliman
khaneliman force-pushed the session-vars-6-self-reference-warning branch from 527e9b9 to 8aee3ac 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-6-self-reference-warning branch 2 times, most recently from aa51f5c to d7eaa33 Compare September 30, 2026 18:58
@khaneliman
khaneliman force-pushed the session-vars-6-self-reference-warning branch from d7eaa33 to 793d075 Compare October 1, 2026 02:11
Warn when session-variable definitions may change if applied more than
once. Apply the check to home and Zsh session variables without changing
their generated output.

Detect direct references after caller-specific rendering while excluding
stable whole-value expansions. Attribute each warning to the surviving
per-attribute definitions, including their module priorities and wrappers.

This gives users advance notice before later work allows the session
configuration to be applied in new shells. Recommend search-variable
options for path-like values and complete assignments for other values.

Tests cover detector boundaries, Zsh escaping, source attribution, and
both module call sites.
@khaneliman
khaneliman force-pushed the session-vars-6-self-reference-warning branch from 793d075 to a796c21 Compare November 18, 2026 01:13

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant