From 98aed449ba2ec9f9c4bc265da37a7666e3ad04bd Mon Sep 17 00:00:00 2001 From: PopeRigby Date: Sat, 2 Aug 2025 10:25:35 -0700 Subject: [PATCH] television: update channel location Co-authored-by: awwpotato --- modules/programs/television.nix | 52 ++++++++++++------- .../programs/television/basic-config.nix | 46 ++++++++-------- 2 files changed, 56 insertions(+), 42 deletions(-) diff --git a/modules/programs/television.nix b/modules/programs/television.nix index 45c73b528..e57bcec85 100644 --- a/modules/programs/television.nix +++ b/modules/programs/television.nix @@ -43,29 +43,41 @@ in default = { }; description = '' Each set of channels are written to - {file}`$XDG_CONFIG_HOME/television/NAME-channels.toml` + {file}`$XDG_CONFIG_HOME/television/cable/NAME.toml` - See + See for options ''; - example = lib.literalExpression '' - { - my-custom = { - cable_channel = [ - { - name = "git-log"; - source_command = "git log --oneline --date=short --pretty=\"format:%h %s %an %cd\" \"$@\""; - preview_command = "git show -p --stat --pretty=fuller --color=always {0}"; - } - { - name = "git-log"; - source_command = "git log --oneline --date=short --pretty=\"format:%h %s %an %cd\" \"$@\""; - preview_command = "git show -p --stat --pretty=fuller --color=always {0}"; - } - ]; + example = { + git-diff = { + metadata = { + name = "git-diff"; + description = "A channel to select files from git diff commands"; + requirements = [ "git" ]; }; - } - ''; + source = { + command = "git diff --name-only HEAD"; + }; + preview = { + command = "git diff HEAD --color=always -- '{}'"; + }; + }; + git-log = { + metadata = { + name = "git-log"; + description = "A channel to select from git log entries"; + requirements = [ "git" ]; + }; + source = { + command = "git log --oneline --date=short --pretty=\"format:%h %s %an %cd\" \"$@\""; + output = "{split: :0}"; + }; + preview = { + command = "git show -p --stat --pretty=fuller --color=always '{0}'"; + }; + }; + }; + }; enableBashIntegration = lib.hm.shell.mkBashIntegrationOption { inherit config; }; @@ -84,7 +96,7 @@ in } (lib.mapAttrs' ( name: value: - lib.nameValuePair "television/${name}-channels.toml" { + lib.nameValuePair "television/cable/${name}.toml" { source = tomlFormat.generate "television-${name}-channels" value; } ) cfg.channels) diff --git a/tests/modules/programs/television/basic-config.nix b/tests/modules/programs/television/basic-config.nix index 6d689f41b..11a943e84 100644 --- a/tests/modules/programs/television/basic-config.nix +++ b/tests/modules/programs/television/basic-config.nix @@ -10,19 +10,19 @@ input_bar_position = "top"; }; }; - channels.my-custom = { - cable_channel = [ - { - name = "git-log"; - source_command = ''git log --oneline --date=short --pretty="format:%h %s %an %cd" "$@"''; - preview_command = "git show -p --stat --pretty=fuller --color=always {0}"; - } - { - name = "my-dotfiles"; - source_command = "fd -t f . $HOME/.config"; - preview_command = "bat -n --color=always {0}"; - } - ]; + channels.git-log = { + metadata = { + name = "git-log"; + description = "A channel to select from git log entries"; + requirements = [ "git" ]; + }; + source = { + command = "git log --oneline --date=short --pretty=\"format:%h %s %an %cd\" \"$@\""; + output = "{split: :0}"; + }; + preview = { + command = "git show -p --stat --pretty=fuller --color=always '{0}'"; + }; }; }; @@ -37,18 +37,20 @@ show_preview_panel = true use_nerd_font_icons = false ''} - assertFileExists home-files/.config/television/my-custom-channels.toml - assertFileContent home-files/.config/television/my-custom-channels.toml \ + assertFileExists home-files/.config/television/cable/git-log.toml + assertFileContent home-files/.config/television/cable/git-log.toml \ ${pkgs.writeText "channels-expected" '' - [[cable_channel]] + [metadata] + description = "A channel to select from git log entries" name = "git-log" - preview_command = "git show -p --stat --pretty=fuller --color=always {0}" - source_command = "git log --oneline --date=short --pretty=\"format:%h %s %an %cd\" \"$@\"" + requirements = ["git"] - [[cable_channel]] - name = "my-dotfiles" - preview_command = "bat -n --color=always {0}" - source_command = "fd -t f . $HOME/.config" + [preview] + command = "git show -p --stat --pretty=fuller --color=always '{0}'" + + [source] + command = "git log --oneline --date=short --pretty=\"format:%h %s %an %cd\" \"$@\"" + output = "{split: :0}" ''} ''; }