From ea77b898e5dfb2a7900a87a1bb73167a6e1a140c Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Tue, 17 Jun 2025 09:05:28 +0200 Subject: fix(package): Set the PYTHONPATH ourselves The propagation mechanism seems to be python exclusive and not something that works inside the `buildRustPackage` function. --- package/package.nix | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/package/package.nix b/package/package.nix index 5a29fad..f4d6eac 100644 --- a/package/package.nix +++ b/package/package.nix @@ -14,6 +14,7 @@ # buildInputs mpv-unwrapped, python3Packages, + python3, ffmpeg, openssl, libffi, @@ -61,7 +62,6 @@ rustPlatform.buildRustPackage (finalAttrs: { ]; buildInputs = [ - python3Packages.yt-dlp mpv-unwrapped.dev ffmpeg openssl @@ -110,7 +110,26 @@ rustPlatform.buildRustPackage (finalAttrs: { }; }; - postInstall = '' + 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) \ @@ -119,6 +138,7 @@ rustPlatform.buildRustPackage (finalAttrs: { # NOTE: We cannot clear the path, because we need access to the $EDITOR. <2025-04-04> wrapProgram $out/bin/yt \ --prefix PATH : ${lib.makeBinPath finalAttrs.buildInputs} \ - --set YTDLP_NO_PLUGINS 1 + --set YTDLP_NO_PLUGINS 1 \ + --set PYTHONPATH ${pythonPath} ''; }) -- cgit 1.4.1