From 4e9693a90312060f7ee59a02762e398573f5d6fc Mon Sep 17 00:00:00 2001 From: winston Date: Thu, 6 Jul 2023 09:20:54 +0200 Subject: [PATCH] feat(discord): add settings generation --- home/apps/default.nix | 1 + home/apps/discord.nix | 44 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 home/apps/discord.nix diff --git a/home/apps/default.nix b/home/apps/default.nix index 8e713ac..a2b98b7 100644 --- a/home/apps/default.nix +++ b/home/apps/default.nix @@ -1,6 +1,7 @@ { imports = [ ./browsers.nix + ./discord.nix ./fonts.nix ./git.nix ./gpg.nix diff --git a/home/apps/discord.nix b/home/apps/discord.nix new file mode 100644 index 0000000..33ce9c7 --- /dev/null +++ b/home/apps/discord.nix @@ -0,0 +1,44 @@ +{ + config, + lib, + pkgs, + ... +}: let + inherit (pkgs.stdenv) isDarwin isLinux; +in { + home.activation.discordSettings = let + themeUrl = flavor: "https://catppuccin.github.io/discord/dist/catppuccin-${flavor}-pink.theme.css"; + css = '' + @import url("${themeUrl "mocha"}") (prefers-color-scheme: dark); + @import url("${themeUrl "latte"}") (prefers-color-scheme: light); + :root { + --font-primary: "IBM Plex Sans", sans-serif; + --font-headline: "IBM Plex Sans", sans-serif; + --font-display: "IBM Plex Sans", sans-serif; + --font-code: "Berkeley Mono", "Symbols Nerd Font", mono; + } + ''; + json = pkgs.writeTextFile { + name = "discord-settings.json"; + text = + lib.generators.toJSON {} + { + SKIP_HOST_UPDATE = true; + openasar = { + inherit css; + setup = true; + }; + trayBalloonShown = false; + }; + }; + path = + if isLinux + then config.xdg.configHome + "/discord/settings.json" + else if isDarwin + then config.home.home + "/Library/Application Support/discord/settings.json" + else throw "unsupported platform"; + in + lib.hm.dag.entryAfter ["writeBoundary"] '' + [ -d "$(dirname "${path}")" ] && cp -f "${json}" "${path}" + ''; +}