diff --git a/modules/programs/tray-tui.nix b/modules/programs/tray-tui.nix new file mode 100644 index 000000000..8ce399b22 --- /dev/null +++ b/modules/programs/tray-tui.nix @@ -0,0 +1,54 @@ +{ + lib, + pkgs, + config, + ... +}: +let + inherit (lib) + mkIf + mkEnableOption + mkPackageOption + mkOption + ; + + cfg = config.programs.tray-tui; + tomlFormat = pkgs.formats.toml { }; +in +{ + meta.maintainers = with lib.hm.maintainers; [ aguirre-matteo ]; + + options.programs.tray-tui = { + enable = mkEnableOption "tray-tui"; + package = mkPackageOption pkgs "tray-tui" { nullable = true; }; + settings = mkOption { + type = tomlFormat.type; + default = { }; + example = { + sorting = false; + columns = 3; + key_map = { + left = "focus_left"; + h = "focus_left"; + right = "focus_right"; + l = "focus_right"; + up = "focus_up"; + j = "focus_up"; + down = "focus_down"; + k = "focus_down"; + }; + }; + description = '' + Configuration settings for tray-tui. All the available options + can be found here: + ''; + }; + }; + + config = mkIf cfg.enable { + home.packages = mkIf (cfg.package != null) [ cfg.package ]; + xdg.configFile."tray-tui/config.toml" = mkIf (cfg.settings != { }) { + source = tomlFormat.generate "tray-tui-config" cfg.settings; + }; + }; +} diff --git a/tests/darwinScrublist.nix b/tests/darwinScrublist.nix index f62c5061f..178fc5aa4 100644 --- a/tests/darwinScrublist.nix +++ b/tests/darwinScrublist.nix @@ -154,6 +154,7 @@ let "tmux" "topgrade" "translate-shell" + "tray-tui" "vifm" "vim-vint" "vimPlugins" diff --git a/tests/modules/programs/tray-tui/config.toml b/tests/modules/programs/tray-tui/config.toml new file mode 100644 index 000000000..dfb92c294 --- /dev/null +++ b/tests/modules/programs/tray-tui/config.toml @@ -0,0 +1,12 @@ +columns = 3 +sorting = false + +[key_map] +down = "focus_down" +h = "focus_left" +j = "focus_up" +k = "focus_down" +l = "focus_right" +left = "focus_left" +right = "focus_right" +up = "focus_up" diff --git a/tests/modules/programs/tray-tui/default.nix b/tests/modules/programs/tray-tui/default.nix new file mode 100644 index 000000000..5abca3ee3 --- /dev/null +++ b/tests/modules/programs/tray-tui/default.nix @@ -0,0 +1 @@ +{ tray-tui-example = ./example-config.nix; } diff --git a/tests/modules/programs/tray-tui/example-config.nix b/tests/modules/programs/tray-tui/example-config.nix new file mode 100644 index 000000000..3d79208a8 --- /dev/null +++ b/tests/modules/programs/tray-tui/example-config.nix @@ -0,0 +1,25 @@ +{ + programs.tray-tui = { + enable = true; + settings = { + sorting = false; + columns = 3; + key_map = { + left = "focus_left"; + h = "focus_left"; + right = "focus_right"; + l = "focus_right"; + up = "focus_up"; + j = "focus_up"; + down = "focus_down"; + k = "focus_down"; + }; + }; + }; + + nmt.script = '' + assertFileExists home-files/.config/tray-tui/config.toml + assertFileContent home-files/.config/tray-tui/config.toml \ + ${./config.toml} + ''; +}