{ config, lib, pkgs, ... }: let cfg = config.ext.programs.vesktop; format = pkgs.formats.json { }; in { options.ext.programs.vesktop = { enable = lib.mkEnableOption "Vesktop"; package = lib.mkPackageOption pkgs "vesktop" { }; autostart = lib.mkEnableOption "autostarting Vesktop"; settings = lib.mkOption { inherit (format) type; description = '' Configuration written to {file}`$XDG_CONFIG_HOME/vesktop/settings.json`. ''; default = { }; }; vencord = { enable = lib.mkEnableOption "Vencord"; useSystemPackage = lib.mkOption { type = lib.types.bool; description = "Use the Vencord package in Nixpkgs, instead of allowing Vesktop to manage its own Vencord install"; default = false; }; settings = lib.mkOption { inherit (format) type; description = '' Configuration of the bundled client mod, Vencord, written to {file}`$XDG_CONFIG_HOME/vesktop/settings/settings.json`. ''; default = { }; }; css = lib.mkOption { type = lib.types.lines; description = '' Style sheet of the bundled client mod, Vencord, written to {file}`$XDG_CONFIG_HOME/vesktop/settings/quickCss.css`. ''; default = ""; }; }; }; config = lib.mkIf cfg.enable { packages = lib.mkMerge [ [ (cfg.package.override { withSystemVencord = cfg.vencord.useSystemPackage; }) ] (lib.mkIf cfg.autostart [ (pkgs.makeAutostartItem { name = "vesktop"; package = pkgs.vesktop; prependExtraArgs = [ "--wayland-text-input-version=3" ]; }) ]) ]; xdg.config.files = lib.mkMerge [ { "vesktop/settings.json" = lib.mkIf (cfg.settings != { }) { generator = format.generate "vesktop-settings.json"; value = cfg.settings; }; } (lib.mkIf cfg.vencord.enable { "vesktop/settings/settings.json" = lib.mkIf (cfg.vencord.settings != { }) { generator = format.generate "vencord-settings.json"; value = cfg.vencord.settings; }; "vesktop/settings/quickCss.css".text = lib.mkIf (cfg.vencord.css != "") cfg.vencord.css; }) ]; }; }