about summary refs log tree commit diff stats
path: root/package
diff options
context:
space:
mode:
Diffstat (limited to 'package')
-rw-r--r--package/package.nix26
1 files 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}
   '';
 })