yt-dlp: use fetchFromGitHub, use nix-update-script, generate manpages with pandoc (#421372)

This commit is contained in:
Sandro
2025-07-22 10:54:41 +02:00
committed by GitHub
+51 -26
View File
@@ -1,15 +1,17 @@
{
lib,
python3Packages,
fetchPypi,
fetchFromGitHub,
ffmpeg-headless,
rtmpdump,
atomicparsley,
pandoc,
installShellFiles,
atomicparsleySupport ? true,
ffmpegSupport ? true,
rtmpSupport ? true,
withAlias ? false, # Provides bin/youtube-dl for backcompat
update-python-libraries,
nix-update-script,
}:
python3Packages.buildPythonApplication rec {
@@ -17,17 +19,21 @@ python3Packages.buildPythonApplication rec {
# The websites yt-dlp deals with are a very moving target. That means that
# downloads break constantly. Because of that, updates should always be backported
# to the latest stable release.
version = "2025.6.30";
version = "2025.06.30";
pyproject = true;
src = fetchPypi {
inherit version;
pname = "yt_dlp";
hash = "sha256-bQroVcClW/zCjf+6gE7IUlublV00pBGRoVYaTOwD2L0=";
src = fetchFromGitHub {
owner = "yt-dlp";
repo = "yt-dlp";
tag = version;
hash = "sha256-dwBe6oXh7G67kfiI6BqiC0ZHzleR7QlfMiTVXWYW85I=";
};
build-system = with python3Packages; [
hatchling
build-system = with python3Packages; [ hatchling ];
nativeBuildInputs = [
installShellFiles
pandoc
];
# expose optional-dependencies, but provide all features
@@ -52,6 +58,21 @@ python3Packages.buildPythonApplication rec {
pythonRelaxDeps = [ "websockets" ];
preBuild = ''
python devscripts/make_lazy_extractors.py
'';
postBuild = ''
python devscripts/prepare_manpage.py yt-dlp.1.temp.md
pandoc -s -f markdown-smart -t man yt-dlp.1.temp.md -o yt-dlp.1
rm yt-dlp.1.temp.md
mkdir -p completions/{bash,fish,zsh}
python devscripts/bash-completion.py completions/bash/yt-dlp
python devscripts/zsh-completion.py completions/zsh/_yt-dlp
python devscripts/fish-completion.py completions/fish/yt-dlp.fish
'';
# Ensure these utilities are available in $PATH:
# - ffmpeg: post-processing & transcoding support
# - rtmpdump: download files over RTMP
@@ -68,25 +89,31 @@ python3Packages.buildPythonApplication rec {
''--prefix PATH : "${lib.makeBinPath packagesToBinPath}"''
];
setupPyBuildFlags = [
"build_lazy_extractors"
];
# Requires network
doCheck = false;
postInstall = lib.optionalString withAlias ''
ln -s "$out/bin/yt-dlp" "$out/bin/youtube-dl"
'';
postInstall =
''
installManPage yt-dlp.1
passthru.updateScript = [
update-python-libraries
(toString ./.)
];
installShellCompletion \
--bash completions/bash/yt-dlp \
--fish completions/fish/yt-dlp.fish \
--zsh completions/zsh/_yt-dlp
meta = with lib; {
homepage = "https://github.com/yt-dlp/yt-dlp/";
install -Dm644 Changelog.md README.md -t "$out/share/doc/yt_dlp"
''
+ lib.optionalString withAlias ''
ln -s "$out/bin/yt-dlp" "$out/bin/youtube-dl"
'';
passthru.updateScript = nix-update-script { };
meta = {
changelog = "https://github.com/yt-dlp/yt-dlp/blob/${version}/Changelog.md";
description = "Command-line tool to download videos from YouTube.com and other sites (youtube-dl fork)";
homepage = "https://github.com/yt-dlp/yt-dlp/";
license = lib.licenses.unlicense;
longDescription = ''
yt-dlp is a youtube-dl fork based on the now inactive youtube-dlc.
@@ -95,12 +122,10 @@ python3Packages.buildPythonApplication rec {
youtube-dl is released to the public domain, which means
you can modify it, redistribute it or use it however you like.
'';
changelog = "https://github.com/yt-dlp/yt-dlp/blob/HEAD/Changelog.md";
license = licenses.unlicense;
maintainers = with maintainers; [
mainProgram = "yt-dlp";
maintainers = with lib.maintainers; [
SuperSandro2000
donteatoreo
];
mainProgram = "yt-dlp";
};
}