From 2d8e5a99343fc7df3ba7a512ea59a98b75166974 Mon Sep 17 00:00:00 2001 From: Ilan Joselevich Date: Tue, 4 Oct 2022 00:53:12 +0300 Subject: [PATCH] discocss: add module Co-authored-by: Mihai Fufezan --- .github/CODEOWNERS | 2 ++ modules/misc/news.nix | 7 +++++ modules/modules.nix | 1 + modules/programs/discocss.nix | 49 +++++++++++++++++++++++++++++++++++ 4 files changed, 59 insertions(+) create mode 100644 modules/programs/discocss.nix diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 3f50db65e..33a52f5cc 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -93,6 +93,8 @@ Makefile @thiagokokada /modules/programs/direnv.nix @rycee +/modules/programs/discocss.nix @Kranzes + /modules/programs/eclipse.nix @rycee /modules/programs/emacs.nix @rycee diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 830864d9b..044ce3933 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -741,6 +741,13 @@ in A new module is available: 'programs.havoc'. ''; } + + { + time = "2022-10-12T23:10:48+00:00"; + message = '' + A new module is available: 'programs.discocss'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index f3e740093..b1bc02040 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -65,6 +65,7 @@ let ./programs/command-not-found/command-not-found.nix ./programs/dircolors.nix ./programs/direnv.nix + ./programs/discocss.nix ./programs/eclipse.nix ./programs/emacs.nix ./programs/eww.nix diff --git a/modules/programs/discocss.nix b/modules/programs/discocss.nix new file mode 100644 index 000000000..e782b5602 --- /dev/null +++ b/modules/programs/discocss.nix @@ -0,0 +1,49 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let cfg = config.programs.discocss; +in { + meta.maintainers = with maintainers; [ kranzes ]; + + options = { + programs.discocss = { + enable = mkEnableOption + "discocss, a tiny Discord CSS injector for Linux and MacOS"; + + package = mkPackageOption pkgs "discocss" { }; + + discordPackage = mkPackageOption pkgs "discord" { }; + + discordAlias = mkOption { + type = types.bool; + default = true; + description = "Whether to alias discocss to discord."; + }; + + css = mkOption { + type = types.str; + default = ""; + description = "The custom CSS for discocss to use."; + }; + }; + }; + + config = mkIf cfg.enable { + assertions = [{ + assertion = cfg.discordAlias + -> !(any (p: p.name == cfg.discord.name) config.home.packages); + message = + "To use discocss with discordAlias you have to remove discord from home.packages, or set discordAlias to false."; + }]; + + home.packages = [ + (cfg.package.override { + discordAlias = cfg.discordAlias; + discord = cfg.discordPackage; + }) + ]; + + xdg.configFile."discocss/custom.css".text = cfg.css; + }; +}