diff --git a/modules/components/config-override.nix b/modules/components/config-override.nix new file mode 100644 index 0000000..7483c28 --- /dev/null +++ b/modules/components/config-override.nix @@ -0,0 +1,115 @@ +# Configuration override system - allows complete manual control +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.programs.dots-hyprland; +in +{ + options.programs.dots-hyprland.overrides = { + # Complete file overrides - when set, completely replaces any generated config + hyprlandConf = mkOption { + type = types.nullOr types.lines; + default = null; + description = '' + Complete hyprland.conf content. When set, completely overrides: + - Any rich hyprland.* configuration options + - Any copied hyprland.conf from source + - Generates the entire file from this content + ''; + example = '' + # Custom Hyprland configuration + general { + gaps_in = 10 + gaps_out = 20 + } + ''; + }; + + quickshellConfig = mkOption { + type = types.nullOr types.lines; + default = null; + description = '' + Complete Config.qml content. When set, completely overrides: + - Any rich quickshell.* configuration options + - Any copied Config.qml from source + - Generates the entire file from this content + ''; + }; + + footConfig = mkOption { + type = types.nullOr types.lines; + default = null; + description = '' + Complete foot.ini content. When set, completely overrides: + - Any rich terminal.* configuration options + - Any copied foot.ini from source + - Generates the entire file from this content + ''; + }; + + # Directory-level overrides + hyprDirectory = mkOption { + type = types.nullOr types.path; + default = null; + description = '' + Complete hypr directory override. When set, copies entire directory + and ignores all hyprland configuration options. + ''; + }; + + quickshellDirectory = mkOption { + type = types.nullOr types.path; + default = null; + description = '' + Complete quickshell directory override. When set, copies entire directory + and ignores all quickshell configuration options. + ''; + }; + }; + + config = mkIf cfg.enable { + # Override warnings + warnings = + (optional (cfg.overrides.hyprlandConf != null && cfg.hyprland != {}) + "dots-hyprland: overrides.hyprlandConf is set, ignoring all hyprland.* options") ++ + (optional (cfg.overrides.quickshellConfig != null && cfg.quickshell != {}) + "dots-hyprland: overrides.quickshellConfig is set, ignoring all quickshell.* options") ++ + (optional (cfg.overrides.footConfig != null && cfg.terminal != {}) + "dots-hyprland: overrides.footConfig is set, ignoring all terminal.* options"); + + # File overrides take absolute priority + xdg.configFile = mkMerge [ + # Hyprland complete override + (mkIf (cfg.overrides.hyprlandConf != null) { + "hypr/hyprland.conf".text = cfg.overrides.hyprlandConf; + }) + + # Quickshell complete override + (mkIf (cfg.overrides.quickshellConfig != null) { + "quickshell/ii/modules/common/Config.qml".text = cfg.overrides.quickshellConfig; + }) + + # Terminal complete override + (mkIf (cfg.overrides.footConfig != null) { + "foot/foot.ini".text = cfg.overrides.footConfig; + }) + + # Directory overrides + (mkIf (cfg.overrides.hyprDirectory != null) { + "hypr" = { + source = cfg.overrides.hyprDirectory; + recursive = true; + }; + }) + + (mkIf (cfg.overrides.quickshellDirectory != null) { + "quickshell" = { + source = cfg.overrides.quickshellDirectory; + recursive = true; + }; + }) + ]; + }; +} diff --git a/modules/components/hyprland-config.nix b/modules/components/hyprland-config.nix index 692dc6c..fa27fb5 100644 --- a/modules/components/hyprland-config.nix +++ b/modules/components/hyprland-config.nix @@ -68,8 +68,8 @@ in }; }; - config = mkIf config.programs.dots-hyprland.enable { - # Generate Hyprland configuration files + config = mkIf (config.programs.dots-hyprland.enable && config.programs.dots-hyprland.overrides.hyprlandConf == null) { + # Only generate if no manual override is set xdg.configFile."hypr/general.conf".text = '' # General Hyprland configuration for dots-hyprland (NixOS-managed) diff --git a/modules/components/quickshell-config.nix b/modules/components/quickshell-config.nix index 925a996..ca1672e 100644 --- a/modules/components/quickshell-config.nix +++ b/modules/components/quickshell-config.nix @@ -208,8 +208,8 @@ in }; }; - config = mkIf config.programs.dots-hyprland.enable { - # Generate the Config.qml file with NixOS-managed values + config = mkIf (config.programs.dots-hyprland.enable && config.programs.dots-hyprland.overrides.quickshellConfig == null) { + # Only generate if no manual override is set xdg.configFile."quickshell/ii/modules/common/Config.qml".text = '' pragma Singleton pragma ComponentBehavior: Bound diff --git a/modules/components/terminal-config.nix b/modules/components/terminal-config.nix index 577c30a..037ec6e 100644 --- a/modules/components/terminal-config.nix +++ b/modules/components/terminal-config.nix @@ -66,8 +66,8 @@ in }; }; - config = mkIf config.programs.dots-hyprland.enable { - # Generate foot configuration + config = mkIf (config.programs.dots-hyprland.enable && config.programs.dots-hyprland.overrides.footConfig == null) { + # Only generate if no manual override is set xdg.configFile."foot/foot.ini".text = '' [main] term=xterm-256color diff --git a/modules/home-manager.nix b/modules/home-manager.nix index 8475a17..567089c 100644 --- a/modules/home-manager.nix +++ b/modules/home-manager.nix @@ -17,6 +17,7 @@ in ./components/hyprland-config.nix ./components/terminal-config.nix ./components/touchegg.nix + ./components/config-override.nix ]; options.programs.dots-hyprland = {