feat(downstream): add easy configuration overrides
- 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
This commit is contained in:
@@ -254,8 +254,11 @@ cat <<EOF > /mnt/etc/nixos/home.nix
|
|||||||
];
|
];
|
||||||
|
|
||||||
# Example: How to override Nomarchy defaults
|
# Example: How to override Nomarchy defaults
|
||||||
# nomarchy.home.terminal = "kitty";
|
# nomarchy.fonts.monospace = "FiraCode Nerd Font";
|
||||||
# nomarchy.home.themeOverride = "catppuccin-mocha";
|
|
||||||
|
# Example: Easy configuration overrides
|
||||||
|
# Place your custom configs in an 'overrides' folder next to home.nix
|
||||||
|
# nomarchy.configOverrides = ./overrides;
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|||||||
@@ -1,26 +1,38 @@
|
|||||||
{ config, pkgs, ... }:
|
{ config, pkgs, lib, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
configDir = ../../config;
|
configDir = ../../config;
|
||||||
|
|
||||||
# Read the contents of the config directory
|
# Read the contents of the upstream config directory
|
||||||
configEntries = builtins.readDir configDir;
|
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/)
|
# Files to explicitly exclude (handled elsewhere or not intended for ~/.config/)
|
||||||
excludedFiles = [
|
excludedFiles = [
|
||||||
"nomarchy.ttf"
|
"nomarchy.ttf"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# Get all unique names from both sources
|
||||||
|
allNames = lib.unique (builtins.attrNames configEntries ++ builtins.attrNames userEntries);
|
||||||
|
|
||||||
# Filter the entries
|
# Filter the entries
|
||||||
validEntries = builtins.filter (name: !(builtins.elem name excludedFiles)) (builtins.attrNames configEntries);
|
validEntries = builtins.filter (name: !(builtins.elem name excludedFiles)) allNames;
|
||||||
|
|
||||||
# Generate the xdg.configFile attribute set
|
# 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.
|
# For directories, we use `recursive = true;` to allow the user to create their own files alongside the read-only defaults.
|
||||||
makeMapping = name: {
|
makeMapping = name: {
|
||||||
inherit name;
|
inherit name;
|
||||||
value = {
|
value = lib.mkDefault {
|
||||||
source = "${configDir}/${name}";
|
source = if userEntries ? ${name}
|
||||||
recursive = configEntries.${name} == "directory";
|
then "${userConfigDir}/${name}"
|
||||||
|
else "${configDir}/${name}";
|
||||||
|
recursive = (userEntries.${name} or configEntries.${name}) == "directory";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -73,5 +73,10 @@
|
|||||||
description = "System monospace font.";
|
description = "System monospace font.";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
configOverrides = lib.mkOption {
|
||||||
|
type = lib.types.nullOr lib.types.path;
|
||||||
|
default = null;
|
||||||
|
description = "Path to a directory containing configuration overrides.";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user