Move the once-per-session guard to the final extra-code section. Plain
and search variables can then refresh without rerunning arbitrary code.
Keep the extra body top-level so shell parse behavior stays unchanged.
Use an exported generation token for Zsh. Changes to generic or
Zsh-specific values reapply both layers, while unchanged nested shells
keep Zsh precedence and do not repeat self-references.
Plain values are re-evaluated each time the file is applied. Command
substitutions run again, and some self-references can change repeatedly.
Removing a variable still requires a new session.
Closes#3999Closes#4559
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.
Add entries after a PATH-like variable's runtime-inherited value.
`home.sessionSearchVariables` still places entries before that value.
`lib.mkAfter` cannot express this. It orders configured entries relative
to each other, but cannot place an entry after a value inherited at
runtime.
On the first merge in a process tree, configured entries are repositioned
according to prepend or append mode. Later merges preserve existing
positions so intervening environment changes are not reordered. An entry
listed in both options therefore takes append position on the first merge
and retains its inherited position later.
Neither option has an `environment.d` counterpart, so neither reaches
systemd user services. Modules that need that set
`systemd.user.sessionVariables` separately.
Switches `home.sessionPath` and `home.sessionSearchVariables` from
concatenation to the merge helper added in the previous commit. The
first merge preserves configured-first search order while removing
duplicate entries. Later merge blocks preserve inherited positions.
Entries that expand to an empty string are ignored. Statically empty
entries also produce an evaluation warning so an accidental
current-directory entry does not disappear silently.
Fish gets a native merge helper because babelfish rejects the POSIX
helper's quoted pattern removal, and Fish stores names ending in PATH as
lists. Candidate assignments and merge calls are translated together so
references to earlier search variables observe the same values as the
POSIX file. The native helper also preserves newline-bearing values
through Fish command substitutions.
A shared behavioral fixture sources both generated files for first and
later merges. It covers expansion and escaping, cross-variable
references, unset and empty values, duplicates, separator-bearing
entries, empty fields, Fish list shape, helper cleanup, and leading,
embedded, and trailing newlines.
Removes `prependToVar`, which has no consumers left and produced the
self-referential form this replaces. It was public through
`lib.hm.shell`, so the release notes include migration guidance.
Adds a POSIX `__hm_merge` helper and one `mergeSearchVariables`
generator. The generator owns helper setup, prepend and append calls,
marker export, and cleanup so callers cannot misorder those stages.
Nothing consumes it yet; `prependToVar` is untouched.
Adding an entry that is already present never duplicates it. Whether an
already-present entry may be moved depends on where the merge runs:
- First merge in a process tree, detected by
`__HM_SESS_VARS_MERGED` being unset: configured entries take their
configured precedence and existing occurrences are repositioned.
- Any later merge: existing entries keep their position, so re-sourcing
cannot reorder a path a development shell, direnv, or a wrapper put in
front.
The complete generator exports the marker after the last merge, then
removes its helper and scratch variables. The marker is deliberately
separate from `__HM_SESS_VARS_SOURCED`, whose position relative to the
merges is not fixed.
Entries expand in a double-quoted shell context. Raw double quotes
remain shell syntax so quoted command substitutions keep working; `\"`
produces a literal quote.
The helper lives in `session-search-merge.sh` rather than a Nix string.
It contains no interpolation, so keeping it as shell source avoids three
layers of escaping and lets shellcheck read it.
Removal is join-based rather than token-splitting. Splitting on the
separator is not idempotent for entries that contain the separator:
merging `a:b` into `x:a:b:y` would grow on every source.
Verified in bash, dash, and zsh across substring entries and globs.
Coverage also includes separator-bearing values, marker transitions,
prepend and append ordering, cleanup, and repeated sourcing.
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.
Forward converted values to the complete settings path so the standard
changed-option warning identifies the destination key. Preserve legacy
reads, priorities, defaults, and shadowed conversions.
Point mpdris2 at Library.music_dir directly and cover nested paths,
literal dotted keys, and the affected callers in warning tests. The
contributor guidelines now describe `to` as the settings path that
contains `key` instead of the settings root.
Document helper inputs, return values, and examples in the library format. Clarify legacy alias declarations and state-version warning modes without changing executable Nix.
Share raw overlay forwarding and effective-key detection for default-empty
legacy options. Keep application defaults and conversions in consumers.
Delegate aliases and diagnostics to doRename without rewrapping prepared
priorities. Cover ordering, composition, empty values, and source filenames
in the existing evaluations.
Add opt-in ordered forwarding to the settings rename helper so legacy and canonical list definitions retain priorities and mkBefore/mkAfter ordering.
Keep the default helper path unchanged and cover evaluation in module scopes without a warnings option.
The Putter tool is a Rust implementation of the file management
component of Home Manager. It takes a JSON manifest that indicates how
files should be symlinked and when the manifest is applied, does its
best to ensure that the file system reflect the manifest.
Putter offers some additional features that Home Manager does not
expose today, such as file copying (potentially recursive) and support
for overriding files within a recursive tree (e.g., inside a symlinked
tree one could ensure that a specific file is copies with specific
permissions).
This is considered highly experimental at the moment and to use Putter
one must set a hidden option.
ckgxrg was added to nixpkgs by NixOS/nixpkgs@ff7b6221c0. Regenerating all-maintainers.nix also restores the existing glmlm entry missing from the generated file.
Avoid repeated attribute lookups and unnecessary intermediate allocations in
DAG helpers. Cache DAG names while normalizing before-edges to improve topoSort
performance on large DAGs.
Co-authored-by: Eman Resu <78693624+quatquatt@users.noreply.github.com>
Add reusable Home Manager generator helpers for rendering freeform attrsets that contain lib.hm.dag entries.
This keeps ordering support available to JSON and future generated formats without forcing each module to carry its own DAG sorting boilerplate.
toHyprconf' tested every important prefix with a non-strict foldl that
always scanned the full list. lib.any expresses the same any-prefix-matches
intent and stops at the first match. Runs once per attribute in the
Hyprland generator.
Extract MCP-related helper functions (renderEnv, mkEnvFilesWrapper,
wrapEnvFilesCommand, addType, transformMcpServer) into a new shared
library module at modules/lib/mcp.nix.
- Add lib.hm.mcp for sharing transformMcpServer logic across consumers
- Add enabled/disabled conflict detection assertion
- Add tests for new library functions
The zsh value renderer emits strings in double quotes so session variables can still expand references such as $HOME. Embedded quotes, backslashes, and backticks were not escaped, which could corrupt generated zsh code or trigger command substitution.
Escape those double-quote-sensitive characters while preserving dollar expansion for existing session-variable semantics.