- Introduce nomarchy.configOverrides option to map a user directory to ~/.config - Implement automatic merging of upstream defaults and user overrides - Use lib.mkDefault for all upstream mappings to allow granular HM overrides - Update installer template with usage examples
43 lines
1.4 KiB
Nix
43 lines
1.4 KiB
Nix
{ config, pkgs, lib, ... }:
|
|
|
|
let
|
|
configDir = ../../config;
|
|
|
|
# Read the contents of the upstream config directory
|
|
configEntries = builtins.readDir configDir;
|
|
|
|
# Check for user overrides
|
|
userConfigDir = config.nomarchy.configOverrides;
|
|
userEntries = if userConfigDir != null && builtins.pathExists userConfigDir
|
|
then builtins.readDir userConfigDir
|
|
else {};
|
|
|
|
# Files to explicitly exclude (handled elsewhere or not intended for ~/.config/)
|
|
excludedFiles = [
|
|
"nomarchy.ttf"
|
|
];
|
|
|
|
# Get all unique names from both sources
|
|
allNames = lib.unique (builtins.attrNames configEntries ++ builtins.attrNames userEntries);
|
|
|
|
# Filter the entries
|
|
validEntries = builtins.filter (name: !(builtins.elem name excludedFiles)) allNames;
|
|
|
|
# Generate the xdg.configFile attribute set
|
|
# If a name exists in userEntries, it takes precedence.
|
|
# For directories, we use `recursive = true;` to allow the user to create their own files alongside the read-only defaults.
|
|
makeMapping = name: {
|
|
inherit name;
|
|
value = lib.mkDefault {
|
|
source = if userEntries ? ${name}
|
|
then "${userConfigDir}/${name}"
|
|
else "${configDir}/${name}";
|
|
recursive = (userEntries.${name} or configEntries.${name}) == "directory";
|
|
};
|
|
};
|
|
|
|
in
|
|
{
|
|
xdg.configFile = builtins.listToAttrs (map makeMapping validEntries);
|
|
}
|