feat(overrides): wire nomarchy.overrides.paths into xdg.configFile

The option surface (`enable`, `paths`) lived in core/home/overrides.nix
since 2026-05-18 but didn't do anything — paths was a reserved
attrset that never reached xdg.configFile.

Now wired: every entry in nomarchy.overrides.paths substitutes the
matching xdg.configFile.<key>.source at lib.mkForce priority, beating
Nomarchy's own lib.mkDefault writes. Other fields on the original
entry (recursive, etc.) survive via the standard module-system merge.

  nomarchy.overrides.paths = {
    "nomarchy/default/hypr/looknfeel.conf" = ./looknfeel.conf;
    "waybar/style.css"                     = ./waybar.css;
  };

Picked the attrset model from the row's two options rather than
runtime ~/.config/nomarchy/overrides/ directory discovery — Nix needs
every managed file declared at evaluation time, and the attrset
matches the explicit-config shape used everywhere else in the
Nomarchy surface.

docs/OPTIONS.md updated: both overrides.{enable,paths} entries get
real content + an example, the configOverrides row now contrasts
bulk-vs-per-file accurately, and the "Where these are defined" footer
drops the (reserved) tag.

`nix flake check --no-build` clean.
This commit is contained in:
Bernardo Magri
2026-05-22 18:49:19 +01:00
parent ce7010bb67
commit 38429a32df
2 changed files with 56 additions and 15 deletions

View File

@@ -2,33 +2,63 @@
# File-based override system for Nomarchy.
#
# STATUS: option surface only — the actual override mechanism is NOT yet
# implemented. The options are kept so configs that already set
# `nomarchy.overrides.enable = …;` continue to evaluate; setting them has
# no effect today. Tracked in docs/ROADMAP.md.
# When `nomarchy.overrides.enable = true` (default), every entry in
# `nomarchy.overrides.paths` substitutes the `xdg.configFile.<key>.source`
# Nomarchy ships by default. The substitution is done with `lib.mkForce`
# so it wins over Nomarchy's own `lib.mkDefault` writes. Other fields on
# the original entry (e.g. `recursive`) survive the merge.
#
# When implemented, this module should substitute sources in
# `xdg.configFile.<path>.source` based on the presence of matching files
# under ~/.config/nomarchy/overrides/.
# Usage in a downstream home.nix:
#
# nomarchy.overrides.paths = {
# "nomarchy/default/hypr/looknfeel.conf" = ./mine/looknfeel.conf;
# "waybar/style.css" = ./mine/waybar.css;
# };
#
# The keys are xdg.configFile paths (i.e. relative to ~/.config/). Drop-
# in-a-dir discovery is intentionally not supported — Nix needs every
# managed file declared at evaluation time, and the attrset is the
# explicit-config shape the rest of the Nomarchy module surface uses.
let
cfg = config.nomarchy.overrides;
in
{
options.nomarchy.overrides = {
enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Reserved for the future file-based override loader. Currently a
no-op setting this has no effect. See docs/ROADMAP.md.
Whether file-based overrides in nomarchy.overrides.paths are
applied. Defaults to true so an empty `paths` is a no-op and
a populated one Just Works without a second toggle.
'';
};
paths = lib.mkOption {
type = lib.types.attrsOf lib.types.path;
default = {};
example = lib.literalExpression ''
{
"nomarchy/default/hypr/looknfeel.conf" = ./looknfeel.conf;
"waybar/style.css" = ./waybar.css;
}
'';
description = ''
Reserved for the future file-based override loader. Currently
unused.
Attribute set mapping xdg.configFile paths (relative to
~/.config/) to Nix paths whose contents should replace the
Nomarchy-shipped source. Each entry deploys at lib.mkForce
priority so it overrides Nomarchy's lib.mkDefault writes;
recursive flags and other fields on the original entry are
preserved. Pointing at a path Nomarchy doesn't manage just
creates a new xdg.configFile entry.
'';
};
};
config = lib.mkIf cfg.enable {
xdg.configFile = lib.mapAttrs (_path: src: {
source = lib.mkForce src;
}) cfg.paths;
};
}