Merge pull request #266926 from nbraud/mpvScripts/buildLua/extraScripts

mpvScripts.buildLua: Add `extraScripts` parameter, infer `scriptName` better

authored by Maciej Krüger and committed by GitHub faf93f97 1aeb6d14

+24 -7
+19 -4
pkgs/applications/video/mpv/scripts/buildLua.nix
··· 1 1 { lib 2 2 , stdenvNoCC }: 3 3 4 - let fileName = pathStr: lib.last (lib.splitString "/" pathStr); 4 + let 5 + escapedList = with lib; concatMapStringsSep " " (s: "'${escape [ "'" ] s}'"); 6 + fileName = pathStr: lib.last (lib.splitString "/" pathStr); 7 + scriptsDir = "$out/share/mpv/scripts"; 5 8 in 6 9 lib.makeOverridable ( 7 - { pname, scriptPath ? "${pname}.lua", ... }@args: 10 + { pname 11 + , extraScripts ? [] 12 + , ... }@args: 13 + let 14 + # either passthru.scriptName, inferred from scriptPath, or from pname 15 + scriptName = (args.passthru or {}).scriptName or ( 16 + if args ? scriptPath 17 + then fileName args.scriptPath 18 + else "${pname}.lua" 19 + ); 20 + scriptPath = args.scriptPath or "./${scriptName}"; 21 + in 8 22 stdenvNoCC.mkDerivation (lib.attrsets.recursiveUpdate { 9 23 dontBuild = true; 10 24 preferLocalBuild = true; ··· 12 26 outputHashMode = "recursive"; 13 27 installPhase = '' 14 28 runHook preInstall 15 - install -m644 -Dt $out/share/mpv/scripts ${scriptPath} 29 + install -m644 -Dt "${scriptsDir}" \ 30 + ${escapedList ([ scriptPath ] ++ extraScripts)} 16 31 runHook postInstall 17 32 ''; 18 33 19 - passthru.scriptName = fileName scriptPath; 34 + passthru = { inherit scriptName; }; 20 35 meta.platforms = lib.platforms.all; 21 36 } args) 22 37 )
+2 -2
pkgs/applications/video/mpv/scripts/quality-menu.nix
··· 15 15 hash = "sha256-yrcTxqpLnOI1Tq3khhflO3wzhyeTPuvKifyH5/P57Ns="; 16 16 }; 17 17 18 - passthru.scriptName = "quality-menu.lua"; 19 - scriptPath = if oscSupport then "*.lua" else passthru.scriptName; 18 + scriptPath = "quality-menu.lua"; 19 + extraScripts = lib.optional oscSupport "quality-menu-osc.lua"; 20 20 21 21 meta = with lib; { 22 22 description = "A userscript for MPV that allows you to change youtube video quality (ytdl-format) on the fly";
+3 -1
pkgs/applications/video/mpv/scripts/thumbnail.nix
··· 15 15 postPatch = "patchShebangs concat_files.py"; 16 16 dontBuild = false; 17 17 18 - scriptPath = "mpv_thumbnail_script_{client_osc,server}.lua"; 18 + scriptPath = "mpv_thumbnail_script_client_osc.lua"; 19 + extraScripts = [ "mpv_thumbnail_script_server.lua" ]; 20 + passthru.scriptName = "mpv_thumbnail_script_{client_osc,server}.lua"; 19 21 20 22 meta = with lib; { 21 23 description = "A lua script to show preview thumbnails in mpv's OSC seekbar";