television: add extraPackages option with default dependencies

Add an extraPackages option to the television module that wraps the `tv`
binary with additional packages in PATH. Defaults to fd, bat, and ripgrep
which are the dependencies required by television's default channels.

Existing tests updated to set extraPackages = [ ] since they test config
generation, not binary wrapping.

💘 Generated with Crush

Assisted-by: Crush:glm-5.2
This commit is contained in:
csanthiago
2026-07-11 15:00:36 -05:00
committed by Austin Horstman
parent 2afec152df
commit 0992a29487
6 changed files with 83 additions and 2 deletions
+31 -1
View File
@@ -18,6 +18,20 @@ in
enable = lib.mkEnableOption "television";
package = lib.mkPackageOption pkgs "television" { nullable = true; };
extraPackages = lib.mkOption {
type = with lib.types; listOf package;
default = with pkgs; [
fd
bat
ripgrep
];
defaultText = lib.literalExpression "with pkgs; [ fd bat ripgrep ]";
example = lib.literalExpression "with pkgs; [ eza ]";
description = ''
Extra packages available to television.
'';
};
settings = lib.mkOption {
inherit (tomlFormat) type;
default = { };
@@ -132,7 +146,23 @@ in
};
config = lib.mkIf cfg.enable {
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
home.packages = lib.mkIf (cfg.package != null) (
if cfg.extraPackages != [ ] then
[
(pkgs.symlinkJoin {
name = "${lib.getName cfg.package}-wrapped-${lib.getVersion cfg.package}";
paths = [ cfg.package ];
preferLocalBuild = true;
nativeBuildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/tv \
--suffix PATH : ${lib.makeBinPath cfg.extraPackages}
'';
})
]
else
[ cfg.package ]
);
xdg.configFile = lib.mkMerge [
{
@@ -1,6 +1,9 @@
{ lib, pkgs, ... }:
{
programs.television.enable = true;
programs.television = {
enable = true;
extraPackages = [ ];
};
programs.nix-search-tv.enable = true;
@@ -2,6 +2,7 @@
{
programs.television = {
enable = true;
extraPackages = [ ];
settings = {
tick_rate = 50;
ui = {
@@ -1,4 +1,5 @@
{
television-basic-config = ./basic-config.nix;
television-extra-packages = ./extra-packages.nix;
television-themes-config = ./themes-config.nix;
}
@@ -0,0 +1,45 @@
{ pkgs, config, ... }:
let
televisionPackage = config.lib.test.mkStubPackage {
name = "television";
buildScript = ''
mkdir -p "$out/bin"
touch "$out/bin/tv"
chmod +x "$out/bin/tv"
'';
};
in
{
programs.television = {
enable = true;
package = televisionPackage;
extraPackages = with pkgs; [
fd
bat
ripgrep
];
};
test.stubs = {
fd = {
name = "fd";
};
bat = {
name = "bat";
};
ripgrep = {
name = "ripgrep";
};
};
nmt = {
description = "Check if the television binary is correctly wrapped with extraPackages in PATH";
script = ''
tvWrapper="$TESTED/home-path/bin/tv"
assertFileExists "$tvWrapper"
assertFileRegex "$tvWrapper" "fd"
assertFileRegex "$tvWrapper" "bat"
assertFileRegex "$tvWrapper" "ripgrep"
'';
};
}
@@ -3,6 +3,7 @@
programs.television = {
enable = true;
package = config.lib.test.mkStubPackage { name = "television"; };
extraPackages = [ ];
settings = {
ui.theme = "default";