···1{ lib
2, callPackage
3, config
4+, runCommand
5}:
67+let
8+ buildLua = callPackage ./buildLua.nix { };
9+10+ unionOfDisjoints = lib.fold lib.attrsets.unionOfDisjoint {};
11+12+ addTests = name: drv: let
13+ inherit (drv) scriptName;
14+ scriptPath = "share/mpv/scripts/${scriptName}";
15+ fullScriptPath = "${drv}/${scriptPath}";
16+17+ in drv.overrideAttrs (old: { passthru = (old.passthru or {}) // { tests = unionOfDisjoints [
18+ (old.passthru.tests or {})
19+20+ {
21+ scriptName-is-valid = runCommand "mpvScripts.${name}.passthru.tests.scriptName-is-valid" {
22+ meta.maintainers = with lib.maintainers; [ nicoo ];
23+ preferLocalBuild = true;
24+ } ''
25+ if [ -e "${fullScriptPath}" ]; then
26+ touch $out
27+ else
28+ echo "mpvScripts.\"${name}\" does not contain a script named \"${scriptName}\"" >&2
29+ exit 1
30+ fi
31+ '';
32+ }
33+34+ # can't check whether `fullScriptPath` is a directory, in pure-evaluation mode
35+ (with lib; optionalAttrs (! any (s: hasSuffix s drv.passthru.scriptName) [ ".js" ".lua" ".so" ]) {
36+ single-main-in-script-dir = runCommand "mpvScripts.${name}.passthru.tests.single-main-in-script-dir" {
37+ meta.maintainers = with lib.maintainers; [ nicoo ];
38+ preferLocalBuild = true;
39+ } ''
40+ die() {
41+ echo "$@" >&2
42+ exit 1
43+ }
44+45+ cd "${drv}/${scriptPath}" # so the glob expands to filenames only
46+ mains=( main.* )
47+ if [ "''${#mains[*]}" -eq 1 ]; then
48+ touch $out
49+ elif [ "''${#mains[*]}" -eq 0 ]; then
50+ die "'${scriptPath}' contains no 'main.*' file"
51+ else
52+ die "'${scriptPath}' contains multiple 'main.*' files:" "''${mains[*]}"
53+ fi
54+ '';
55+ })
56+ ]; }; });
57+in
58+59+lib.recurseIntoAttrs
60+ (lib.mapAttrs addTests ({
61 acompressor = callPackage ./acompressor.nix { inherit buildLua; };
62 autocrop = callPackage ./autocrop.nix { };
63 autodeint = callPackage ./autodeint.nix { };
···81 vr-reversal = callPackage ./vr-reversal.nix { };
82 webtorrent-mpv-hook = callPackage ./webtorrent-mpv-hook.nix { };
83 }
84+ // (callPackage ./occivink.nix { inherit buildLua; })))
85 // lib.optionalAttrs config.allowAliases {
86 youtube-quality = throw "'youtube-quality' is no longer maintained, use 'quality-menu' instead"; # added 2023-07-14
87}
+2
pkgs/applications/video/mpv/scripts/mpvacious.nix
···32 runHook postInstall
33 '';
340035 meta = with lib; {
36 description = "Adds mpv keybindings to create Anki cards from movies and TV shows";
37 homepage = "https://github.com/Ajatt-Tools/mpvacious";
···32 runHook postInstall
33 '';
3435+ passthru.scriptName = "mpvacious";
36+37 meta = with lib; {
38 description = "Adds mpv keybindings to create Anki cards from movies and TV shows";
39 homepage = "https://github.com/Ajatt-Tools/mpvacious";
···13 };
1415 scriptPath = ".";
16- passthru.scriptName = "webui.lua";
1718 meta = with lib; {
19 description = "A web based user interface with controls for the mpv mediaplayer";
···13 };
1415 scriptPath = ".";
16+ passthru.scriptName = "webui";
1718 meta = with lib; {
19 description = "A web based user interface with controls for the mpv mediaplayer";