diff options
Diffstat (limited to '')
-rw-r--r-- | pkgs/by-name/yt/yt/package.nix | 115 |
1 files changed, 85 insertions, 30 deletions
diff --git a/pkgs/by-name/yt/yt/package.nix b/pkgs/by-name/yt/yt/package.nix index 3c780374..c6533158 100644 --- a/pkgs/by-name/yt/yt/package.nix +++ b/pkgs/by-name/yt/yt/package.nix @@ -1,39 +1,65 @@ +# 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, + python3Packages, python3, - rustPlatform, + ffmpeg, + openssl, + libffi, + # NativeBuildInputs + makeWrapper, + llvmPackages_latest, + glibc, 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.6.1"; 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-vVmn0uPQ5t5wcrRbvabD7SOHR2hIjH2NdTE4hJaE3rk="; + }; + + buildInputs = [ + python3Packages.yt-dlp + mpv-unwrapped.dev + ffmpeg + openssl + libffi + ]; + nativeBuildInputs = [ + installShellFiles makeWrapper sqlite fd + pkg-config + ]; + + checkInputs = [ + # Needed for the tests in `libmpv2` + SDL2 ]; passthru.updateScript = gitUpdater {rev-prefix = "v";}; @@ -43,27 +69,56 @@ 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])); + # 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; 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="; + cargoHash = "sha256-6xRBXHSYUeOqRk2C5LmEwm4YLuiEjLcFDMokSMHuGXQ="; + + postInstall = let + collectDeps = pkg: let + next = pkg.propagatedBuildInputs or []; + in + [pkg] + ++ next + ++ (lib.flatten (builtins.map collectDeps next)); + + loadPythonDep = der: "${der}/lib/python${lib.versions.majorMinor python3.version}/site-packages"; + + pythonPath = builtins.concatStringsSep ":" (lib.lists.unique ( + builtins.map loadPythonDep ( + (collectDeps python3Packages.yt-dlp) + ++ [ + # HACK(@bpeetz): These packages are not picked up in the traversal up top. <2025-06-16> + python3Packages.chardet + ] + ) + )); + in '' + installShellCompletion --cmd yt \ + --bash <(COMPLETE=bash $out/bin/yt) \ + --fish <(COMPLETE=fish $out/bin/yt) \ + --zsh <(COMPLETE=zsh $out/bin/yt) - postInstall = '' + # 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 \ + --set PYTHONPATH ${pythonPath} ''; - } + }) |