mpvScripts.buildLua: Only accept plain scriptPath, no glob etc.

This makes future support for directory-packaged scripts much easier.

An `extraScripts` parameter is provided for packaging scripts which
expect multiple files (or folders) in `mpv/scripts/`, even though
this does not comply with mpv's documented script location:

  https://mpv.io/manual/master/#script-location
This commit is contained in:
nicoo 2023-11-11 21:32:48 +00:00
parent e8c0fde6b3
commit 588e73db43

View File

@ -1,10 +1,17 @@
{ lib
, stdenvNoCC }:
let fileName = pathStr: lib.last (lib.splitString "/" pathStr);
let
escapedList = with lib; concatMapStringsSep " " (s: "'${escape [ "'" ] s}'");
fileName = pathStr: lib.last (lib.splitString "/" pathStr);
scriptsDir = "$out/share/mpv/scripts";
in
lib.makeOverridable (
{ pname, scriptPath ? "${pname}.lua", ... }@args:
{ pname
, scriptPath ? "${pname}.lua"
, extraScripts ? []
, ... }@args:
stdenvNoCC.mkDerivation (lib.attrsets.recursiveUpdate {
dontBuild = true;
preferLocalBuild = true;
@ -12,7 +19,8 @@ lib.makeOverridable (
outputHashMode = "recursive";
installPhase = ''
runHook preInstall
install -m644 -Dt $out/share/mpv/scripts ${scriptPath}
install -m644 -Dt "${scriptsDir}" \
${escapedList ([ scriptPath ] ++ extraScripts)}
runHook postInstall
'';