nixpkgs/pkgs/by-name/yt/ytdownloader/package.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

83 lines
2.2 KiB
Nix
Raw Normal View History

{
lib,
buildNpmPackage,
fetchFromGitHub,
copyDesktopItems,
makeWrapper,
ffmpeg,
yt-dlp,
makeDesktopItem,
electron,
2024-03-07 14:37:35 +00:00
}:
buildNpmPackage rec {
pname = "ytDownloader";
2024-10-11 08:51:36 +00:00
version = "3.18.3";
2024-03-07 14:37:35 +00:00
src = fetchFromGitHub {
owner = "aandrew-me";
repo = "ytDownloader";
rev = "refs/tags/v${version}";
2024-10-11 08:51:36 +00:00
hash = "sha256-omq1krlHj0+SvyofQtJnVBiQzHPIC/v/WhXGClm0vzM=";
2024-03-07 14:37:35 +00:00
};
2024-10-11 08:51:36 +00:00
npmDepsHash = "sha256-PE9RWdnUlHTCBqGN6xvq+B7gXke/KsKsGcg1SAy7bfs=";
2024-03-07 14:37:35 +00:00
nativeBuildInputs = [
copyDesktopItems
makeWrapper
];
buildInputs = [
ffmpeg
yt-dlp
];
2024-03-07 14:37:35 +00:00
desktopItems = [
(makeDesktopItem {
name = "ytDownloader";
exec = "ytdownloader %U";
icon = "ytdownloader";
desktopName = "ytDownloader";
comment = "A modern GUI video and audio downloader";
categories = [ "Utility" ];
startupWMClass = "ytDownloader";
})
];
2024-03-07 14:37:35 +00:00
ELECTRON_SKIP_BINARY_DOWNLOAD = "1";
dontNpmBuild = true;
# Patch config dir to ~/.config/ytdownloader
# Otherwise it stores config in ~/.config/Electron
patches = [ ./config-dir.patch ];
2024-03-07 14:37:35 +00:00
# Replace hardcoded ffmpeg and ytdlp paths
# Also stop it from downloading ytdlp
postPatch = ''
substituteInPlace src/renderer.js \
--replace-fail $\{__dirname}/../ffmpeg '${lib.getExe ffmpeg}' \
--replace-fail 'path.join(os.homedir(), ".ytDownloader", "ytdlp")' '`${lib.getExe yt-dlp}`' \
--replace-fail '!!localStorage.getItem("fullYtdlpBinPresent")' 'true'
2024-06-02 21:50:04 +00:00
# Disable auto-updates
substituteInPlace src/preferences.js \
--replace-warn 'const autoUpdateDisabled = getId("autoUpdateDisabled");' 'const autoUpdateDisabled = "true";'
2024-03-07 14:37:35 +00:00
'';
postInstall = ''
makeWrapper ${electron}/bin/electron $out/bin/ytdownloader \
--add-flags $out/lib/node_modules/ytdownloader/main.js
install -Dm444 assets/images/icon.png $out/share/pixmaps/ytdownloader.png
'';
meta = {
description = "Modern GUI video and audio downloader";
homepage = "https://github.com/aandrew-me/ytDownloader";
license = lib.licenses.gpl3Only;
maintainers = with lib.maintainers; [ chewblacka ];
platforms = lib.platforms.all;
mainProgram = "ytdownloader";
};
}