{ config, lib, ... }: # File-based override system for Nomarchy. # # When `nomarchy.overrides.enable = true` (default), every entry in # `nomarchy.overrides.paths` substitutes the `xdg.configFile..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. # # 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 = '' 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 = '' 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; }; }