From 084df7a420e6ecf4bee407001bfbd88f32894577 Mon Sep 17 00:00:00 2001 From: Ross Smyth <18294397+RossSmyth@users.noreply.github.com> Date: Fri, 29 Aug 2025 12:34:49 -0400 Subject: [PATCH] television: Refactor, add wrapper helper --- pkgs/by-name/te/television/package.nix | 133 ++++++++++++++++--------- pkgs/by-name/te/television/wrapper.nix | 33 ++++++ 2 files changed, 119 insertions(+), 47 deletions(-) create mode 100644 pkgs/by-name/te/television/wrapper.nix diff --git a/pkgs/by-name/te/television/package.nix b/pkgs/by-name/te/television/package.nix index ee92352468e8..55a1b4ad9517 100644 --- a/pkgs/by-name/te/television/package.nix +++ b/pkgs/by-name/te/television/package.nix @@ -1,60 +1,99 @@ { lib, + stdenv, rustPlatform, fetchFromGitHub, - makeWrapper, - testers, - television, + callPackage, + installShellFiles, nix-update-script, - extraPackages ? [ ], + testers, + targetPackages, + extraPackages ? null, }: -rustPlatform.buildRustPackage (finalAttrs: { - pname = "television"; - version = "0.13.5"; - src = fetchFromGitHub { - owner = "alexpasmantier"; - repo = "television"; - tag = finalAttrs.version; - hash = "sha256-IlFOYnZ9xPQaRheielKqAckyVlSVQMhnO4wCtVixlNQ="; - }; +assert + (extraPackages == null) + || lib.warn "Overriding television with the 'extraPackages' attribute is deprecated. Please use `television.withPackages (p: [ p.fd ...])` instead."; - cargoHash = "sha256-QKUspbC1bmSeZP0n/O5roEqQkrja+fVKLhAvgzqNS9E="; +let + television = rustPlatform.buildRustPackage (finalAttrs: { + pname = "television"; - nativeBuildInputs = [ makeWrapper ]; + version = "0.13.5"; - postInstall = lib.optionalString (extraPackages != [ ]) '' - wrapProgram $out/bin/tv \ - --prefix PATH : ${lib.makeBinPath extraPackages} - ''; - - # TODO(@getchoo): Investigate selectively disabling some tests, or fixing them - # https://github.com/NixOS/nixpkgs/pull/423662#issuecomment-3156362941 - doCheck = false; - - passthru = { - tests.version = testers.testVersion { - package = television; - command = "XDG_DATA_HOME=$TMPDIR tv --version"; + src = fetchFromGitHub { + owner = "alexpasmantier"; + repo = "television"; + tag = finalAttrs.version; + hash = "sha256-IlFOYnZ9xPQaRheielKqAckyVlSVQMhnO4wCtVixlNQ="; }; - updateScript = nix-update-script { }; - }; - meta = { - description = "Blazingly fast general purpose fuzzy finder TUI"; - longDescription = '' - Television is a fast and versatile fuzzy finder TUI. - It lets you quickly search through any kind of data source (files, git - repositories, environment variables, docker images, you name it) using a - fuzzy matching algorithm and is designed to be easily extensible. - ''; - homepage = "https://github.com/alexpasmantier/television"; - changelog = "https://github.com/alexpasmantier/television/releases/tag/${finalAttrs.version}"; - license = lib.licenses.mit; - mainProgram = "tv"; - maintainers = with lib.maintainers; [ - louis-thevenet - getchoo + cargoHash = "sha256-QKUspbC1bmSeZP0n/O5roEqQkrja+fVKLhAvgzqNS9E="; + + strictDeps = true; + nativeBuildInputs = [ + installShellFiles ]; - }; -}) + + # TODO(@getchoo): Investigate selectively disabling some tests, or fixing them + # https://github.com/NixOS/nixpkgs/pull/423662#issuecomment-3156362941 + doCheck = false; + + postInstall = '' + installManPage target/${stdenv.hostPlatform.rust.cargoShortTarget}/assets/tv.1 + + installShellCompletion --cmd tv \ + television/utils/shell/completion.bash \ + television/utils/shell/completion.fish \ + television/utils/shell/completion.nu \ + television/utils/shell/completion.zsh + ''; + + passthru = { + updateScript = nix-update-script { }; + + withPackages = + f: + callPackage ./wrapper.nix { + television = finalAttrs.finalPackage; + extraPackages = f targetPackages; + }; + + tests = { + version = testers.testVersion { + package = finalAttrs.finalPackage; + command = "XDG_DATA_HOME=$TMPDIR tv --version"; + }; + wrapper = testers.testVersion { + package = finalAttrs.finalPackage.withPackages (pkgs: [ + pkgs.fd + pkgs.git + ]); + + command = "XDG_DATA_HOME=$TMPDIR tv --version"; + }; + }; + }; + + meta = { + description = "Blazingly fast general purpose fuzzy finder TUI"; + longDescription = '' + Television is a fast and versatile fuzzy finder TUI. + It lets you quickly search through any kind of data source (files, git + repositories, environment variables, docker images, you name it) using a + fuzzy matching algorithm and is designed to be easily extensible. + ''; + homepage = "https://github.com/alexpasmantier/television"; + changelog = "https://github.com/alexpasmantier/television/releases/tag/${finalAttrs.version}"; + license = lib.licenses.mit; + mainProgram = "tv"; + maintainers = with lib.maintainers; [ + louis-thevenet + getchoo + RossSmyth + ]; + }; + }); +in + +if extraPackages == null then television else television.withPackages (lib.const extraPackages) diff --git a/pkgs/by-name/te/television/wrapper.nix b/pkgs/by-name/te/television/wrapper.nix new file mode 100644 index 000000000000..75725f0051df --- /dev/null +++ b/pkgs/by-name/te/television/wrapper.nix @@ -0,0 +1,33 @@ +{ + lib, + symlinkJoin, + television, + makeBinaryWrapper, + extraPackages, +}: + +symlinkJoin { + inherit (television) version; + pname = "${television.pname}-with-pkgs"; + + paths = [ television ]; + + nativeBuildInputs = [ makeBinaryWrapper ]; + + postBuild = '' + wrapProgram $out/bin/tv \ + --prefix PATH : "${lib.makeBinPath extraPackages}" + ''; + + meta = { + inherit (television.meta) + description + longDescription + homepage + changelog + license + mainProgram + maintainers + ; + }; +}