diff --git a/modules/programs/twitch-tui.nix b/modules/programs/twitch-tui.nix new file mode 100644 index 000000000..b11c46133 --- /dev/null +++ b/modules/programs/twitch-tui.nix @@ -0,0 +1,56 @@ +{ + lib, + pkgs, + config, + ... +}: +let + inherit (lib) + mkIf + mkEnableOption + mkPackageOption + mkOption + ; + + cfg = config.programs.twitch-tui; + tomlFormat = pkgs.formats.toml { }; +in +{ + meta.maintainers = with lib.hm.maintainers; [ aguirre-matteo ]; + + options.programs.twitch-tui = { + enable = mkEnableOption "twitch-tui"; + package = mkPackageOption pkgs "twitch-tui" { nullable = true; }; + settings = mkOption { + type = tomlFormat.type; + default = { }; + example = { + twitch = { + username = ""; + channel = ""; + server = "wss://eventsub.wss.twitch.tv/ws"; + token = ""; + }; + + terminal = { + delay = 30; + maximum_messages = 500; + log_file = ""; + log_level = "info"; + first_state = "dashboard"; + }; + }; + description = '' + Configuration settings for twitch-tui. All the available options + can be found here: + ''; + }; + }; + + config = mkIf cfg.enable { + home.packages = mkIf (cfg.package != null) [ cfg.package ]; + xdg.configFile."twt/config.toml" = mkIf (cfg.settings != { }) { + source = tomlFormat.generate "twitch-tui-config" cfg.settings; + }; + }; +} diff --git a/tests/modules/programs/twitch-tui/config.toml b/tests/modules/programs/twitch-tui/config.toml new file mode 100644 index 000000000..e24462c70 --- /dev/null +++ b/tests/modules/programs/twitch-tui/config.toml @@ -0,0 +1,12 @@ +[terminal] +delay = 30 +first_state = "dashboard" +log_file = "" +log_level = "info" +maximum_messages = 500 + +[twitch] +channel = "" +server = "wss://eventsub.wss.twitch.tv/ws" +token = "" +username = "" diff --git a/tests/modules/programs/twitch-tui/default.nix b/tests/modules/programs/twitch-tui/default.nix new file mode 100644 index 000000000..dc5ff1b26 --- /dev/null +++ b/tests/modules/programs/twitch-tui/default.nix @@ -0,0 +1 @@ +{ twitch-tui-example = ./example-config.nix; } diff --git a/tests/modules/programs/twitch-tui/example-config.nix b/tests/modules/programs/twitch-tui/example-config.nix new file mode 100644 index 000000000..c47222a06 --- /dev/null +++ b/tests/modules/programs/twitch-tui/example-config.nix @@ -0,0 +1,27 @@ +{ + programs.twitch-tui = { + enable = true; + settings = { + twitch = { + username = ""; + channel = ""; + server = "wss://eventsub.wss.twitch.tv/ws"; + token = ""; + }; + + terminal = { + delay = 30; + maximum_messages = 500; + log_file = ""; + log_level = "info"; + first_state = "dashboard"; + }; + }; + }; + + nmt.script = '' + assertFileExists home-files/.config/twt/config.toml + assertFileContent home-files/.config/twt/config.toml \ + ${./config.toml} + ''; +}