diff options
Diffstat (limited to 'nixpkgs/pkgs/applications/video/mpv/scripts')
12 files changed, 153 insertions, 135 deletions
diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/acompressor.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/acompressor.nix deleted file mode 100644 index d82d12f163e7..000000000000 --- a/nixpkgs/pkgs/applications/video/mpv/scripts/acompressor.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ lib -, buildLua -, mpv-unwrapped -}: - -buildLua { - inherit (mpv-unwrapped) src version; - pname = "mpv-acompressor"; - scriptPath = "TOOLS/lua/acompressor.lua"; - - meta = with lib; { - inherit (mpv-unwrapped.meta) license; - description = "Script to toggle and control ffmpeg's dynamic range compression filter."; - homepage = "https://github.com/mpv-player/mpv/blob/master/TOOLS/lua/acompressor.lua"; - maintainers = with maintainers; [ nicoo ]; - }; -} diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/autocrop.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/autocrop.nix deleted file mode 100644 index 645a4dd16899..000000000000 --- a/nixpkgs/pkgs/applications/video/mpv/scripts/autocrop.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ stdenvNoCC, mpv-unwrapped, lib }: - -stdenvNoCC.mkDerivation rec { - pname = "mpv-autocrop"; - version = mpv-unwrapped.version; - src = "${mpv-unwrapped.src.outPath}/TOOLS/lua/autocrop.lua"; - dontBuild = true; - dontUnpack = true; - installPhase = '' - install -Dm644 ${src} $out/share/mpv/scripts/autocrop.lua - ''; - passthru.scriptName = "autocrop.lua"; - - meta = { - description = "This script uses the lavfi cropdetect filter to automatically insert a crop filter with appropriate parameters for the currently playing video."; - homepage = "https://github.com/mpv-player/mpv/blob/master/TOOLS/lua/autocrop.lua"; - license = lib.licenses.gpl2Plus; - }; -} diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/autodeint.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/autodeint.nix deleted file mode 100644 index b5369b748faf..000000000000 --- a/nixpkgs/pkgs/applications/video/mpv/scripts/autodeint.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ stdenvNoCC, mpv-unwrapped, lib }: - -stdenvNoCC.mkDerivation rec { - pname = "mpv-autodeint"; - version = mpv-unwrapped.version; - src = "${mpv-unwrapped.src.outPath}/TOOLS/lua/autodeint.lua"; - dontBuild = true; - dontUnpack = true; - installPhase = '' - install -Dm644 ${src} $out/share/mpv/scripts/autodeint.lua - ''; - passthru.scriptName = "autodeint.lua"; - - meta = { - description = "This script uses the lavfi idet filter to automatically insert the appropriate deinterlacing filter based on a short section of the currently playing video."; - homepage = "https://github.com/mpv-player/mpv/blob/master/TOOLS/lua/autodeint.lua"; - license = lib.licenses.gpl2Plus; - }; -} diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/autoload.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/autoload.nix deleted file mode 100644 index c4a85c50d938..000000000000 --- a/nixpkgs/pkgs/applications/video/mpv/scripts/autoload.nix +++ /dev/null @@ -1,20 +0,0 @@ -{ stdenvNoCC, mpv-unwrapped, lib }: - -stdenvNoCC.mkDerivation rec { - pname = "mpv-autoload"; - version = mpv-unwrapped.version; - src = "${mpv-unwrapped.src.outPath}/TOOLS/lua/autoload.lua"; - dontBuild = true; - dontUnpack = true; - installPhase = '' - install -Dm644 ${src} $out/share/mpv/scripts/autoload.lua - ''; - passthru.scriptName = "autoload.lua"; - - meta = { - description = "This script automatically loads playlist entries before and after the currently played file"; - homepage = "https://github.com/mpv-player/mpv/blob/master/TOOLS/lua/autoload.lua"; - maintainers = [ lib.maintainers.dawidsowa ]; - license = lib.licenses.gpl2Plus; - }; -} diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/buildLua.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/buildLua.nix index c7f510253f94..0027fa722596 100644 --- a/nixpkgs/pkgs/applications/video/mpv/scripts/buildLua.nix +++ b/nixpkgs/pkgs/applications/video/mpv/scripts/buildLua.nix @@ -2,7 +2,6 @@ , stdenvNoCC }: let - inherit (lib) hasPrefix hasSuffix removeSuffix; escapedList = with lib; concatMapStringsSep " " (s: "'${escape [ "'" ] s}'"); fileName = pathStr: lib.last (lib.splitString "/" pathStr); scriptsDir = "$out/share/mpv/scripts"; @@ -37,6 +36,9 @@ lib.makeOverridable (args: stdenvNoCC.mkDerivation (extendedBy dontBuild = true; preferLocalBuild = true; + # Prevent `patch` from emitting `.orig` files (that end up in the output) + patchFlags = [ "--no-backup-if-mismatch" "-p1" ]; + outputHashMode = "recursive"; installPhase = '' runHook preInstall @@ -52,7 +54,7 @@ lib.makeOverridable (args: stdenvNoCC.mkDerivation (extendedBy exit 1 } mkdir -p "${scriptsDir}" - cp -a "${scriptPath}" "${scriptsDir}/${lib.removeSuffix ".lua" scriptName}" + cp -a "${scriptPath}" "${scriptsDir}/${scriptName}" else install -m644 -Dt "${scriptsDir}" \ ${escapedList ([ scriptPath ] ++ extraScripts)} diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/default.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/default.nix index a529bf00ac6b..158a7c491007 100644 --- a/nixpkgs/pkgs/applications/video/mpv/scripts/default.nix +++ b/nixpkgs/pkgs/applications/video/mpv/scripts/default.nix @@ -1,35 +1,98 @@ { lib -, callPackage , config +, newScope +, runCommand }: -let buildLua = callPackage ./buildLua.nix { }; -in lib.recurseIntoAttrs - ({ - acompressor = callPackage ./acompressor.nix { inherit buildLua; }; - autocrop = callPackage ./autocrop.nix { }; - autodeint = callPackage ./autodeint.nix { }; - autoload = callPackage ./autoload.nix { }; - chapterskip = callPackage ./chapterskip.nix { inherit buildLua; }; - convert = callPackage ./convert.nix { inherit buildLua; }; - cutter = callPackage ./cutter.nix { inherit buildLua; }; +let + unionOfDisjoints = lib.fold lib.attrsets.unionOfDisjoint {}; + + addTests = name: drv: + if ! lib.isDerivation drv then + drv + else let + inherit (drv) scriptName; + scriptPath = "share/mpv/scripts/${scriptName}"; + fullScriptPath = "${drv}/${scriptPath}"; + in drv.overrideAttrs (old: { passthru = (old.passthru or {}) // { tests = unionOfDisjoints [ + (old.passthru.tests or {}) + + { + scriptName-is-valid = runCommand "mpvScripts.${name}.passthru.tests.scriptName-is-valid" { + meta.maintainers = with lib.maintainers; [ nicoo ]; + preferLocalBuild = true; + } '' + if [ -e "${fullScriptPath}" ]; then + touch $out + else + echo "mpvScripts.\"${name}\" does not contain a script named \"${scriptName}\"" >&2 + exit 1 + fi + ''; + } + + # can't check whether `fullScriptPath` is a directory, in pure-evaluation mode + (with lib; optionalAttrs (! any (s: hasSuffix s drv.passthru.scriptName) [ ".js" ".lua" ".so" ]) { + single-main-in-script-dir = runCommand "mpvScripts.${name}.passthru.tests.single-main-in-script-dir" { + meta.maintainers = with lib.maintainers; [ nicoo ]; + preferLocalBuild = true; + } '' + die() { + echo "$@" >&2 + exit 1 + } + + cd "${drv}/${scriptPath}" # so the glob expands to filenames only + mains=( main.* ) + if [ "''${#mains[*]}" -eq 1 ]; then + touch $out + elif [ "''${#mains[*]}" -eq 0 ]; then + die "'${scriptPath}' contains no 'main.*' file" + else + die "'${scriptPath}' contains multiple 'main.*' files:" "''${mains[*]}" + fi + ''; + }) + ]; }; }); + + scope = self: let + inherit (self) callPackage; + in lib.mapAttrs addTests { + inherit (callPackage ./mpv.nix { }) + acompressor autocrop autodeint autoload; + inherit (callPackage ./occivink.nix { }) + blacklistExtensions seekTo; + + buildLua = callPackage ./buildLua.nix { }; + chapterskip = callPackage ./chapterskip.nix { }; + convert = callPackage ./convert.nix { }; + cutter = callPackage ./cutter.nix { }; inhibit-gnome = callPackage ./inhibit-gnome.nix { }; mpris = callPackage ./mpris.nix { }; - mpv-playlistmanager = callPackage ./mpv-playlistmanager.nix { inherit buildLua; }; - mpv-webm = callPackage ./mpv-webm.nix { inherit buildLua; }; - mpvacious = callPackage ./mpvacious.nix { inherit buildLua; }; - quality-menu = callPackage ./quality-menu.nix { inherit buildLua; }; - simple-mpv-webui = callPackage ./simple-mpv-webui.nix { inherit buildLua; }; + mpv-playlistmanager = callPackage ./mpv-playlistmanager.nix { }; + mpv-webm = callPackage ./mpv-webm.nix { }; + mpvacious = callPackage ./mpvacious.nix { }; + quality-menu = callPackage ./quality-menu.nix { }; + simple-mpv-webui = callPackage ./simple-mpv-webui.nix { }; sponsorblock = callPackage ./sponsorblock.nix { }; - sponsorblock-minimal = callPackage ./sponsorblock-minimal.nix { inherit buildLua; }; - thumbfast = callPackage ./thumbfast.nix { inherit buildLua; }; - thumbnail = callPackage ./thumbnail.nix { inherit buildLua; }; - uosc = callPackage ./uosc.nix { inherit buildLua; }; - visualizer = callPackage ./visualizer.nix { inherit buildLua; }; + sponsorblock-minimal = callPackage ./sponsorblock-minimal.nix { }; + thumbfast = callPackage ./thumbfast.nix { }; + thumbnail = callPackage ./thumbnail.nix { }; + uosc = callPackage ./uosc.nix { }; + visualizer = callPackage ./visualizer.nix { }; vr-reversal = callPackage ./vr-reversal.nix { }; webtorrent-mpv-hook = callPackage ./webtorrent-mpv-hook.nix { }; - } - // (callPackage ./occivink.nix { inherit buildLua; })) - // lib.optionalAttrs config.allowAliases { - youtube-quality = throw "'youtube-quality' is no longer maintained, use 'quality-menu' instead"; # added 2023-07-14 -} + }; + + aliases = { + youtube-quality = throw "'youtube-quality' is no longer maintained, use 'quality-menu' instead"; # added 2023-07-14 + }; +in + +with lib; pipe scope [ + (makeScope newScope) + (self: + assert builtins.intersectAttrs self aliases == {}; + self // optionalAttrs config.allowAliases aliases) + recurseIntoAttrs +] diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/mpv-playlistmanager.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/mpv-playlistmanager.nix index c164bae1495d..ec25801edd22 100644 --- a/nixpkgs/pkgs/applications/video/mpv/scripts/mpv-playlistmanager.nix +++ b/nixpkgs/pkgs/applications/video/mpv/scripts/mpv-playlistmanager.nix @@ -2,13 +2,13 @@ buildLua rec { pname = "mpv-playlistmanager"; - version = "unstable-2023-08-09"; + version = "unstable-2023-11-28"; src = fetchFromGitHub { owner = "jonniek"; repo = "mpv-playlistmanager"; - rev = "e479cbc7e83a07c5444f335cfda13793681bcbd8"; - sha256 = "sha256-Nh4g8uSkHWPjwl5wyqWtM+DW9fkEbmCcOsZa4eAF6Cs="; + rev = "579490c7ae1becc129736b7632deec4f3fb90b99"; + hash = "sha256-swOtoB8UV/HPTpQRGXswAfUYsyC2Nj/QRIkGP8X1jk0="; }; postPatch = '' diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/mpv.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/mpv.nix new file mode 100644 index 000000000000..06e9ccb4d74a --- /dev/null +++ b/nixpkgs/pkgs/applications/video/mpv/scripts/mpv.nix @@ -0,0 +1,35 @@ +{ lib +, buildLua +, mpv-unwrapped +}: + +let mkBuiltin = name: args: + let srcPath = "TOOLS/lua/${name}.lua"; + in buildLua (lib.attrsets.recursiveUpdate rec { + inherit (mpv-unwrapped) src version; + pname = "mpv-${name}"; + + dontUnpack = true; + scriptPath = "${src}/${srcPath}"; + + meta = with lib; { + inherit (mpv-unwrapped.meta) license; + homepage = "https://github.com/mpv-player/mpv/blob/v${version}/${srcPath}"; + }; + } args); + +in lib.mapAttrs (name: lib.makeOverridable (mkBuiltin name)) { + acompressor.meta = { + description = "Script to toggle and control ffmpeg's dynamic range compression filter."; + maintainers = with lib.maintainers; [ nicoo ]; + }; + + autocrop.meta.description = "This script uses the lavfi cropdetect filter to automatically insert a crop filter with appropriate parameters for the currently playing video."; + + autodeint.meta.description = "This script uses the lavfi idet filter to automatically insert the appropriate deinterlacing filter based on a short section of the currently playing video."; + + autoload.meta = { + description = "This script automatically loads playlist entries before and after the currently played file"; + maintainers = [ lib.maintainers.dawidsowa ]; + }; +} diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/mpvacious.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/mpvacious.nix index 93e1402289cd..9c1c6ce80f62 100644 --- a/nixpkgs/pkgs/applications/video/mpv/scripts/mpvacious.nix +++ b/nixpkgs/pkgs/applications/video/mpv/scripts/mpvacious.nix @@ -32,6 +32,8 @@ buildLua rec { runHook postInstall ''; + passthru.scriptName = "mpvacious"; + meta = with lib; { description = "Adds mpv keybindings to create Anki cards from movies and TV shows"; homepage = "https://github.com/Ajatt-Tools/mpvacious"; diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/occivink.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/occivink.nix index 167e2fef6ac0..f4ea27c1c1aa 100644 --- a/nixpkgs/pkgs/applications/video/mpv/scripts/occivink.nix +++ b/nixpkgs/pkgs/applications/video/mpv/scripts/occivink.nix @@ -1,5 +1,6 @@ { lib , fetchFromGitHub +, unstableGitUpdater , buildLua }: @@ -10,15 +11,16 @@ let in stringAsChars (c: if isUpper c != null then "-${toLower c}" else c); mkScript = name: args: - buildLua (lib.attrsets.recursiveUpdate rec { + let self = rec { pname = camelToKebab name; + version = "unstable-2023-12-18"; src = fetchFromGitHub { owner = "occivink"; repo = "mpv-scripts"; - rev = "af360f332897dda907644480f785336bc93facf1"; - hash = "sha256-KdCrUkJpbxxqmyUHksVVc8KdMn8ivJeUA2eerFZfEE8="; + rev = "f0426bd6b107b1f4b124552dae923b62f58ce3b6"; + hash = "sha256-oag5lcDoezyNXs5EBr0r0UE3ikeftvbfxSzfbxV1Oy0="; }; - version = "unstable-2022-10-02"; + passthru.updateScript = unstableGitUpdater {}; scriptPath = "scripts/${pname}.lua"; @@ -27,19 +29,17 @@ let license = licenses.unlicense; maintainers = with maintainers; [ nicoo ]; }; - } args); + + # Sadly needed to make `common-updaters` work here + pos = builtins.unsafeGetAttrPos "version" self; + }; + in buildLua (lib.attrsets.recursiveUpdate self args); in lib.mapAttrs (name: lib.makeOverridable (mkScript name)) { # Usage: `pkgs.mpv.override { scripts = [ pkgs.mpvScripts.seekTo ]; }` - seekTo = { - meta.description = "Mpv script for seeking to a specific position"; - outputHash = "sha256-3RlbtUivmeoR9TZ6rABiZSd5jd2lFv/8p/4irHMLshs="; - }; - - blacklistExtensions = { - meta.description = "Automatically remove playlist entries based on their extension."; - outputHash = "sha256-qw9lz8ofmvvh23F9aWLxiU4YofY+YflRETu+nxMhvVE="; - }; + seekTo.meta.description = "Mpv script for seeking to a specific position"; + blacklistExtensions.meta.description = + "Automatically remove playlist entries based on their extension."; } diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/simple-mpv-webui.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/simple-mpv-webui.nix index c3b53c618396..b1f3f4595632 100644 --- a/nixpkgs/pkgs/applications/video/mpv/scripts/simple-mpv-webui.nix +++ b/nixpkgs/pkgs/applications/video/mpv/scripts/simple-mpv-webui.nix @@ -13,7 +13,7 @@ buildLua rec { }; scriptPath = "."; - passthru.scriptName = "webui.lua"; + passthru.scriptName = "webui"; meta = with lib; { description = "A web based user interface with controls for the mpv mediaplayer"; diff --git a/nixpkgs/pkgs/applications/video/mpv/scripts/sponsorblock.nix b/nixpkgs/pkgs/applications/video/mpv/scripts/sponsorblock.nix index 35f5fcb549f1..077b8f0590b2 100644 --- a/nixpkgs/pkgs/applications/video/mpv/scripts/sponsorblock.nix +++ b/nixpkgs/pkgs/applications/video/mpv/scripts/sponsorblock.nix @@ -1,7 +1,7 @@ -{ lib, stdenvNoCC, fetchFromGitHub, fetchpatch, python3, nix-update-script }: +{ lib, buildLua, fetchFromGitHub, fetchpatch, python3, nix-update-script }: # Usage: `pkgs.mpv.override { scripts = [ pkgs.mpvScripts.sponsorblock ]; }` -stdenvNoCC.mkDerivation { +buildLua { pname = "mpv_sponsorblock"; version = "unstable-2023-01-30"; @@ -12,8 +12,6 @@ stdenvNoCC.mkDerivation { sha256 = "sha256-iUXaTWWFEdxhxClu2NYbQcThlvYty3A2dEYGooeAVAQ="; }; - dontBuild = true; - patches = [ # Use XDG_DATA_HOME and XDG_CACHE_HOME if defined for UID and DB # Necessary to avoid sponsorblock to write in the nix store at runtime. @@ -34,23 +32,16 @@ stdenvNoCC.mkDerivation { --replace 'mp.find_config_file("scripts")' "\"$out/share/mpv/scripts\"" ''; - installPhase = '' - mkdir -p $out/share/mpv/scripts - cp -r sponsorblock.lua sponsorblock_shared $out/share/mpv/scripts/ - ''; + postInstall = "cp -a sponsorblock_shared $out/share/mpv/scripts/"; - passthru = { - scriptName = "sponsorblock.lua"; - updateScript = nix-update-script { - extraArgs = [ "--version=branch" ]; - }; + passthru.updateScript = nix-update-script { + extraArgs = [ "--version=branch" ]; }; meta = with lib; { description = "Script for mpv to skip sponsored segments of YouTube videos"; homepage = "https://github.com/po5/mpv_sponsorblock"; license = licenses.gpl3; - platforms = platforms.all; maintainers = with maintainers; [ pacien ]; }; } |