discord: combine nixcord, vencord, and vesktop modules (#854)

Link: https://github.com/danth/stylix/pull/854

Reviewed-by: Daniel Thwaites <danth@danth.me>
Reviewed-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
This commit is contained in:
Flameopathic 2025-02-17 16:00:51 -05:00 committed by GitHub
parent 21d68dab9d
commit 7feb1c29bf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 102 additions and 93 deletions

67
modules/discord/hm.nix Normal file
View file

@ -0,0 +1,67 @@
{
config,
lib,
pkgs,
options,
...
}:
let
template =
let
inherit (config.lib.stylix) colors;
inherit (config.stylix) fonts;
in
import ./template.nix { inherit colors fonts; };
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 config.stylix.enable (
lib.mkMerge [
(lib.mkIf config.stylix.targets.vencord.enable {
xdg.configFile."Vencord/themes/stylix.theme.css".text = template;
})
(lib.mkIf 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;
})
]
))
(lib.mkIf config.stylix.targets.nixcord.enable (
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" ];
}
))
]
);
}

View file

@ -0,0 +1,21 @@
{ 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"
];
}

View file

@ -0,0 +1,14 @@
{ pkgs, ... }:
let
package = pkgs.vesktop;
in
{
stylix.testbed.application = {
enable = true;
name = "vesktop";
inherit package;
};
environment.systemPackages = [ package ];
}

View file

@ -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" ];
}
);
}

View file

@ -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;
};
}

View file

@ -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;
})
]
);
}