Commit Graph

343 Commits

Author SHA1 Message Date
Austin Horstman
1553bea9ff home-environment: refresh session vars in shells
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 #3999
Closes #4559
2026-09-30 21:06:23 -05:00
Austin Horstman
793d075a50 lib/shell: warn on self-referential session variables
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.
2026-09-30 21:06:23 -05:00
Austin Horstman
19e005c9b2 home-environment: add sessionSearchVariablesAppend
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.
2026-09-30 21:06:23 -05:00
Austin Horstman
04d39635a6 home-environment: merge search variables idempotently
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.
2026-09-30 21:06:23 -05:00
Austin Horstman
70f396347a lib/shell: add idempotent search-variable merge primitives
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.
2026-09-30 21:06:12 -05:00
Austin Horstman
8db8fb9ce3 lib/shell: handle unset search variables
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.
2026-09-30 21:06:12 -05:00
o-az
f0807df654 maintainers: add o-az 2026-09-30 16:47:55 +02:00
hectorgray
395ff18c63 maintainers: add hectorgray 2026-09-24 18:24:37 -05:00
Austin Horstman
e9796a288e lib/deprecations: name exact settings destinations
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.
2026-09-23 22:37:57 -05:00
Austin Horstman
cfcda3f993 lib.deprecations: simplify settings migrations (#9953) 2026-09-13 21:18:31 -05:00
Drew Davis
fab877f9b2 maintainers: add typeparameter 2026-09-13 10:01:07 -05:00
Austin Horstman
fdc36b1280 lib/deprecations: use nixpkgs-style docstrings
Document helper inputs, return values, and examples in the library format. Clarify legacy alias declarations and state-version warning modes without changing executable Nix.
2026-09-12 23:16:50 -05:00
Austin Horstman
bdcb842903 lib/deprecations: preserve settings overlay definitions
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.
2026-09-12 23:16:50 -05:00
Austin Horstman
e16bc72cbb lib/deprecations: preserve ordered settings renames
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.
2026-09-12 23:16:50 -05:00
Austin Horstman
10d0acd7f8 lib.strings: move systemd escaping into strings
Reuse the existing strings category and keep the systemd-specific names explicit. Update the caller and test registration together.
2026-09-12 21:48:39 -05:00
Austin Horstman
eef2def9ee lib.systemd: tighten comments and test messages
Keep the escaping rationale and test failures concise without changing behavior.
2026-09-12 21:48:39 -05:00
Austin Horstman
9cc74ef628 lib.systemd: add Exec argument escaping helpers
Expose systemd-specific argument quoting without depending on NixOS utilities. Cover argument boundaries, substitutions, supported types, and string context.
2026-09-12 21:48:39 -05:00
Austin Horstman
73be48878b maintainers: remove libewa duplicate
The updated Nixpkgs pin includes libewa in lib.maintainers.
2026-09-11 22:23:22 -05:00
Robert Helgesson
8e89a2340a home-manager: optionally use putter for file management
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.
2026-09-09 21:34:48 +02:00
Antonio Spadaro
f938f20731 firefoxpwa: add ilovelinux as maintainer 2026-09-05 18:46:00 -05:00
EKHH
29388c8114 maintainers: add ekhh 2026-09-01 21:50:53 -05:00
Austin Horstman
42c3fc301e maintainers: remove duplicate nixpkgs maintainers
Remove the Home Manager entries for nikp123 and rachitvrma now that nixpkgs provides them.
2026-08-22 01:19:16 -05:00
Austin Horstman
aac4965ddb antigravity-cli: use lib.hm.mcp.resolveEnabled for MCP server resolution
Export resolveEnabled from lib.hm.mcp and use it in antigravity-cli.
Add test cases for direct disabled and enabled declarations.
2026-08-16 20:11:26 -05:00
K900
0668fdbc15 treewide: stdenv.is* -> stdenv.hostPlatform.is*
Nixpkgs officialy deprecated the former.
2026-08-13 08:40:58 +02:00
Rachit Kumar Verma
c1b62f9b55 maintainers: update rachitvrma 2026-08-06 10:41:14 -05:00
Vidhan Bhatt
ff1741309e maintainers: add vidhanio
Add myself to the Home Manager maintainer list.
2026-08-05 10:43:29 -05:00
Rachit Kumar Verma
63bd543c9e maintainers: add rachitvrma 2026-08-05 10:21:22 -05:00
MithicSpirit
3d25fa94cf lib: option to escape tabs in lib.hm.generators.toKDL
Disabled by default for backwards compatibility.

Enabled for zellij and niri as per escapeBackslashes.
2026-07-28 15:16:56 -05:00
Austin Horstman
0df0df1aee maintainers: ckgxrg moved to nixpkgs
ckgxrg was added to nixpkgs by NixOS/nixpkgs@ff7b6221c0. Regenerating all-maintainers.nix also restores the existing glmlm entry missing from the generated file.
2026-07-28 12:55:08 -05:00
Austin Horstman
7a0f860e66 maintainers: rsahwe moved to nixpkgs
rsahwe was added to nixpkgs by NixOS/nixpkgs#509659:

44f87293db
2026-07-28 12:55:08 -05:00
glmlm
b8324779d1 wayland.windowManager.niri: add myself as module maintainer 2026-07-28 12:35:56 +02:00
Eman Resu
411408f523 lib/file-type: partially apply hasPrefix and removePrefix 2026-07-20 23:17:54 +02:00
reesilva
a1fc9a1cc3 maintainers: add reesilva 2026-07-08 17:33:28 -05:00
Austin Horstman
cf0c5c3e9f maintainers: drop duplicate yarn entry
Remove HM-only yarn maintainer definition and keep module references aligned with nixpkgs maintainer data.
2026-07-04 22:28:41 -05:00
_
d32537981c lib: escape backslash in lib.hm.generators.toKDL 2026-06-30 23:49:47 -05:00
Austin Horstman
9eec3ef087 maintainers: remove quoted names in set
Prefer underscore to match nixpkgs.
2026-06-29 11:12:43 -05:00
Austin Horstman
789a35fbde maintainers: remove duplicate maintainers 2026-06-28 22:04:23 -05:00
Eman Resu
0f4a317c06 lib.hm.dag: performance improvements
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>
2026-06-18 21:53:23 -05:00
Austin Horstman
6716d811e5 lib: add DAG-aware format generators
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.
2026-06-18 07:59:18 -05:00
csanthiago
a20c21b2fe maintainers: add csanthiago
💘 Generated with Crush

Assisted-by: Crush:glm-5.2
2026-06-17 19:16:21 -05:00
Peter Bittner
bfc003171b maintainers: add bittner 2026-06-17 15:47:24 -05:00
Austin Horstman
ce68ac6958 lib/generators: short-circuit important-field check with any
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.
2026-06-17 13:04:43 -05:00
ErinaYip
7664e05e24 maintainers: add ErinaYip 2026-06-16 22:42:18 -05:00
superflash41
6cf5b64c12 maintainers: add superflash41 2026-06-10 09:48:41 -05:00
Malik
6a66db1360 mcp: extract helper functions into lib/mcp.nix
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
2026-06-09 23:03:52 -05:00
Austin Horstman
d33c97ec1b lib/strings: add isPathLike helper 2026-06-05 11:39:28 -05:00
Nikhil Singh
5fadbec07a maintainers: add semi710 2026-06-05 11:13:52 -05:00
Austin Horstman
5ded124f91 lib: add deprecated option warning helpers 2026-06-04 12:20:09 -05:00
Kays
a7c15f4f65 maintainers: add kayskayskays 2026-06-02 08:56:09 -05:00
Austin Horstman
c7c139f742 zsh: escape double-quoted values
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.
2026-06-01 21:22:13 -05:00