diff --git a/installer/install-nomarchy.sh b/installer/install-nomarchy.sh index d16d516..89faf53 100644 --- a/installer/install-nomarchy.sh +++ b/installer/install-nomarchy.sh @@ -254,8 +254,11 @@ cat < /mnt/etc/nixos/home.nix ]; # Example: How to override Nomarchy defaults - # nomarchy.home.terminal = "kitty"; - # nomarchy.home.themeOverride = "catppuccin-mocha"; + # nomarchy.fonts.monospace = "FiraCode Nerd Font"; + + # Example: Easy configuration overrides + # Place your custom configs in an 'overrides' folder next to home.nix + # nomarchy.configOverrides = ./overrides; } EOF diff --git a/modules/home/configs.nix b/modules/home/configs.nix index d08bf89..4dc2122 100644 --- a/modules/home/configs.nix +++ b/modules/home/configs.nix @@ -1,26 +1,38 @@ -{ config, pkgs, ... }: +{ config, pkgs, lib, ... }: let configDir = ../../config; - # Read the contents of the config directory + # 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)) (builtins.attrNames configEntries); + 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 = { - source = "${configDir}/${name}"; - recursive = configEntries.${name} == "directory"; + value = lib.mkDefault { + source = if userEntries ? ${name} + then "${userConfigDir}/${name}" + else "${configDir}/${name}"; + recursive = (userEntries.${name} or configEntries.${name}) == "directory"; }; }; diff --git a/modules/home/options.nix b/modules/home/options.nix index bff1e9b..0243d87 100644 --- a/modules/home/options.nix +++ b/modules/home/options.nix @@ -73,5 +73,10 @@ description = "System monospace font."; }; }; + configOverrides = lib.mkOption { + type = lib.types.nullOr lib.types.path; + default = null; + description = "Path to a directory containing configuration overrides."; + }; }; }