1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-12-07 09:31:04 +01:00

television: add support for channels (#7026)

This commit is contained in:
awwpotato 2025-05-10 18:08:10 -07:00 committed by GitHub
parent 9ef92f1c6b
commit de496c9ccb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 73 additions and 6 deletions

View file

@ -18,6 +18,11 @@ in
settings = lib.mkOption { settings = lib.mkOption {
type = tomlFormat.type; type = tomlFormat.type;
default = { }; default = { };
description = ''
Configuration written to {file}`$XDG_CONFIG_HOME/television/config.toml`.
See <https://github.com/alexpasmantier/television/blob/main/.config/config.toml>
for the full list of options.
'';
example = lib.literalExpression '' example = lib.literalExpression ''
{ {
tick_rate = 50; tick_rate = 50;
@ -31,10 +36,35 @@ in
}; };
} }
''; '';
};
channels = lib.mkOption {
type = lib.types.attrsOf tomlFormat.type;
default = { };
description = '' description = ''
Configuration written to {file}`$XDG_CONFIG_HOME/television/config.toml`. Each set of channels are written to
See <https://github.com/alexpasmantier/television/blob/main/.config/config.toml> {file}`$XDG_CONFIG_HOME/television/NAME-channels.toml`
for the full list of options.
See <https://github.com/alexpasmantier/television/blob/main/docs/channels.md>
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}";
}
];
};
}
''; '';
}; };
@ -46,9 +76,19 @@ in
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ]; home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
xdg.configFile."television/config.toml" = lib.mkIf (cfg.settings != { }) { xdg.configFile = lib.mkMerge [
{
"television/config.toml" = lib.mkIf (cfg.settings != { }) {
source = tomlFormat.generate "config.toml" cfg.settings; source = tomlFormat.generate "config.toml" cfg.settings;
}; };
}
(lib.mapAttrs' (
name: value:
lib.nameValuePair "television/${name}-channels.toml" {
source = tomlFormat.generate "television-${name}-channels" value;
}
) cfg.channels)
];
programs.bash.initExtra = lib.mkIf cfg.enableBashIntegration '' programs.bash.initExtra = lib.mkIf cfg.enableBashIntegration ''
eval "$(${lib.getExe cfg.package} init bash)" eval "$(${lib.getExe cfg.package} init bash)"

View file

@ -10,6 +10,20 @@
input_bar_position = "top"; 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}";
}
];
};
}; };
nmt.script = '' nmt.script = ''
@ -23,5 +37,18 @@
show_preview_panel = true show_preview_panel = true
use_nerd_font_icons = false use_nerd_font_icons = false
''} ''}
assertFileExists home-files/.config/television/my-custom-channels.toml
assertFileContent home-files/.config/television/my-custom-channels.toml \
${pkgs.writeText "channels-expected" ''
[[cable_channel]]
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\" \"$@\""
[[cable_channel]]
name = "my-dotfiles"
preview_command = "bat -n --color=always {0}"
source_command = "fd -t f . $HOME/.config"
''}
''; '';
} }