diff --git a/modules/discord/hm.nix b/modules/discord/hm.nix new file mode 100644 index 000000000..da923764b --- /dev/null +++ b/modules/discord/hm.nix @@ -0,0 +1,68 @@ +{ + config, + lib, + pkgs, + options, + ... +}: +let + template = + let + inherit (config.lib.stylix) colors; + inherit (config.stylix) fonts; + in + import ./template.nix { inherit colors fonts; }; + cfg = config.stylix; +in +{ + options.stylix.targets = + let + inherit (config.lib.stylix) mkEnableTarget; + in + { + vencord.enable = mkEnableTarget "Vencord" true; + vesktop.enable = mkEnableTarget "Vesktop" true; + nixcord.enable = mkEnableTarget "Nixcord" true; + }; + + config = lib.mkIf cfg.enable ( + lib.mkMerge [ + (lib.mkIf cfg.targets.vencord.enable { + xdg.configFile."Vencord/themes/stylix.theme.css".text = template; + }) + + (lib.mkIf cfg.targets.vesktop.enable ( + lib.mkMerge [ + (lib.mkIf pkgs.stdenv.hostPlatform.isLinux { + xdg.configFile."vesktop/themes/stylix.theme.css".text = template; + }) + + (lib.mkIf pkgs.stdenv.hostPlatform.isDarwin { + home.file."Library/Application Support/vesktop/themes/stylix.theme.css".text = + template; + }) + ] + )) + + (lib.mkIf ((config.programs ? nixcord) && cfg.targets.nixcord.enable) ( + lib.optionalAttrs (builtins.hasAttr "nixcord" options.programs) { + # possible the above `hasAttr` condition is unnecessary because of the `config.programs ? nixcord` condition + xdg.configFile = + let + inherit (config.programs) nixcord; + in + lib.mkMerge [ + (lib.mkIf nixcord.discord.enable { + "Vencord/themes/stylix.theme.css".text = template; + }) + + (lib.mkIf nixcord.vesktop.enable { + "vesktop/themes/stylix.theme.css".text = template; + }) + ]; + programs.nixcord.config.enabledThemes = [ "stylix.theme.css" ]; + } + )) + ] + ); +} diff --git a/modules/vencord/template.nix b/modules/discord/template.nix similarity index 100% rename from modules/vencord/template.nix rename to modules/discord/template.nix diff --git a/modules/vesktop/testbed.nix b/modules/discord/testbed.nix similarity index 100% rename from modules/vesktop/testbed.nix rename to modules/discord/testbed.nix diff --git a/modules/nixcord/hm.nix b/modules/nixcord/hm.nix deleted file mode 100644 index c3a3e6d27..000000000 --- a/modules/nixcord/hm.nix +++ /dev/null @@ -1,41 +0,0 @@ -{ - config, - lib, - options, - ... -}: -let - template = - let - inherit (config.lib.stylix) colors; - inherit (config.stylix) fonts; - in - import ../vencord/template.nix { inherit colors fonts; }; - cfg = config.stylix.targets.nixcord; -in -{ - options.stylix.targets.nixcord.enable = - config.lib.stylix.mkEnableTarget "Nixcord" true; - - config = - lib.mkIf (config.stylix.enable && cfg.enable && (config.programs ? nixcord)) - ( - lib.optionalAttrs (builtins.hasAttr "nixcord" options.programs) { - xdg.configFile = - let - inherit (config.programs) nixcord; - in - lib.mkMerge [ - (lib.mkIf nixcord.discord.enable { - "Vencord/themes/stylix.theme.css".text = template; - }) - - (lib.mkIf nixcord.vesktop.enable { - "vesktop/themes/stylix.theme.css".text = template; - }) - ]; - - programs.nixcord.config.enabledThemes = [ "stylix.theme.css" ]; - } - ); -} diff --git a/modules/vencord/hm.nix b/modules/vencord/hm.nix deleted file mode 100644 index ceb661203..000000000 --- a/modules/vencord/hm.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ config, lib, ... }: -let - template = - let - inherit (config.lib.stylix) colors; - inherit (config.stylix) fonts; - in - import ./template.nix { inherit colors fonts; }; -in -{ - options.stylix.targets.vencord.enable = - config.lib.stylix.mkEnableTarget "Vencord" true; - - config = - lib.mkIf (config.stylix.enable && config.stylix.targets.vencord.enable) - { - xdg.configFile."Vencord/themes/stylix.theme.css".text = template; - }; -} diff --git a/modules/vencord/testbed.nix b/modules/vencord/testbed.nix deleted file mode 100644 index 1fcaef05e..000000000 --- a/modules/vencord/testbed.nix +++ /dev/null @@ -1,21 +0,0 @@ -{ lib, pkgs, ... }: - -let - package = pkgs.discord.override { - withVencord = true; - }; -in -{ - stylix.testbed.application = { - enable = true; - name = "discord"; - inherit package; - }; - - environment.systemPackages = [ package ]; - nixpkgs.config.allowUnfreePredicate = - pkg: - builtins.elem (lib.getName pkg) [ - "discord" - ]; -} diff --git a/modules/vesktop/hm.nix b/modules/vesktop/hm.nix deleted file mode 100644 index 90b7e1801..000000000 --- a/modules/vesktop/hm.nix +++ /dev/null @@ -1,33 +0,0 @@ -{ - pkgs, - config, - lib, - ... -}: -let - template = - let - inherit (config.lib.stylix) colors; - inherit (config.stylix) fonts; - in - import ../vencord/template.nix { inherit colors fonts; }; -in -{ - options.stylix.targets.vesktop.enable = - config.lib.stylix.mkEnableTarget "Vesktop" true; - - config = - lib.mkIf (config.stylix.enable && config.stylix.targets.vesktop.enable) - ( - lib.mkMerge [ - (lib.mkIf pkgs.stdenv.hostPlatform.isLinux { - xdg.configFile."vesktop/themes/stylix.theme.css".text = template; - }) - - (lib.mkIf pkgs.stdenv.hostPlatform.isDarwin { - home.file."Library/Application Support/vesktop/themes/stylix.theme.css".text = - template; - }) - ] - ); -}