diff options
Diffstat (limited to '')
-rw-r--r-- | pkgs/by-name/yt/yt/package.nix | 113 |
1 files changed, 83 insertions, 30 deletions
diff --git a/pkgs/by-name/yt/yt/package.nix b/pkgs/by-name/yt/yt/package.nix index 3c780374..b17e9120 100644 --- a/pkgs/by-name/yt/yt/package.nix +++ b/pkgs/by-name/yt/yt/package.nix @@ -1,39 +1,73 @@ +# nixos-config - My current NixOS configuration +# +# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de> +# SPDX-License-Identifier: GPL-3.0-or-later +# +# This file is part of my nixos-config. +# +# You should have received a copy of the License along with this program. +# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>. { + lib, + rustPlatform, + installShellFiles, fetchgit, - ffmpeg, gitUpdater, - glibc, - lib, - llvmPackages_latest, - makeWrapper, + # buildInputs mpv-unwrapped, + ffmpeg, + openssl, + libffi, + zlib, + curl, + # NativeBuildInputs python3, - rustPlatform, + makeWrapper, + llvmPackages_latest, + glibc, + mold-wrapped, sqlite, fd, + pkg-config, + SDL2, }: let - version = "1.5.0"; - - src = fetchgit { - url = "https://git.foss-syndicate.org/bpeetz/clients/yt"; - rev = "v${version}"; - hash = "sha256-P/mpF2KPjoC7XZ6juJubeGEHhL2ajdOeiuIEb5sYrS0="; - }; - - buildInputs = [ - (python3.withPackages (ps: [ps.yt-dlp])) - mpv-unwrapped.dev - ffmpeg - ]; + version = "1.8.0"; + python = python3.withPackages (ps: [ps.yt-dlp]); in - rustPlatform.buildRustPackage { - inherit version src buildInputs; + rustPlatform.buildRustPackage (finalAttrs: { + inherit version; pname = "yt"; + src = fetchgit { + url = "https://git.foss-syndicate.org/bpeetz/clients/yt"; + tag = "v${version}"; + hash = "sha256-J1fGNV/0vjNzF/no7ffE4Sxyr3g5/zDzb2EPcSiqN2o="; + }; + + cargoHash = "sha256-U7yLOhrDBnzNotW+zWjR9s0VzoropSJneo3LPn9VcAA="; + + buildInputs = [ + mpv-unwrapped.dev + ffmpeg + openssl + libffi + zlib + curl.dev + python + ]; + nativeBuildInputs = [ + installShellFiles makeWrapper sqlite fd + pkg-config + mold-wrapped + ]; + + checkInputs = [ + # Needed for the tests in `libmpv2` + SDL2 ]; passthru.updateScript = gitUpdater {rev-prefix = "v";}; @@ -43,27 +77,46 @@ in lib.versions.major llvmPackages_latest.clang-unwrapped.version; in { + # Needed for the compile time sqlite checks. + DATABASE_URL = "sqlite://database.sqlx"; + + # Required by yt_dlp FFMPEG_LOCATION = "${lib.getExe ffmpeg}"; - PYO3_PYTHON = lib.getExe (python3.withPackages (ps: [ps.yt-dlp])); + # Tell pyo3 which python to use. + PYO3_PYTHON = lib.getExe python; + + # Needed for the libmpv2. C_INCLUDE_PATH = "${glibc.dev}/include"; - DATABASE_URL = "sqlite://target/database.sqlx"; LIBCLANG_INCLUDE_PATH = "${llvmPackages_latest.clang-unwrapped.lib}/lib/clang/${clang_version}/include"; LIBCLANG_PATH = "${llvmPackages_latest.clang-unwrapped.lib}/lib/libclang.so"; }; - # Some tests depend on network access, others require a special library. - doCheck = false; + doCheck = true; + checkFlags = [ + # All of these tests try to connect to the internet to download test data. + "--skip=select::base::test_base" + "--skip=select::file::test_file" + "--skip=select::options::test_options" + "--skip=subscriptions::import_export::test_import_export" + "--skip=subscriptions::naming_subscriptions::test_naming_subscriptions" + "--skip=videos::downloading::test_downloading" + ]; prePatch = '' + # Generate the sqlite db, so that we can run the comp-time sqlite checks. bash ./scripts/mkdb.sh ''; - useFetchCargoVendor = true; - cargoHash = "sha256-0XTbC+mFsczUFXqAtiQ+BIsCfKilerhlzE41pzVjLVs="; - postInstall = '' + installShellCompletion --cmd yt \ + --bash <(COMPLETE=bash $out/bin/yt) \ + --fish <(COMPLETE=fish $out/bin/yt) \ + --zsh <(COMPLETE=zsh $out/bin/yt) + + # NOTE: We cannot clear the path, because we need access to the $EDITOR. <2025-04-04> wrapProgram $out/bin/yt \ - --prefix PATH : ${lib.makeBinPath buildInputs} + --prefix PATH : ${lib.makeBinPath finalAttrs.buildInputs} \ + --set YTDLP_NO_PLUGINS 1 ''; - } + }) |