Unverified Commit e8b0430b authored by Maciej Krüger's avatar Maciej Krüger Committed by GitHub
Browse files

Merge pull request #266505 from nbraud/mpvScripts/simple-mpv-webui

parents d783b604 183a4ceb
Loading
Loading
Loading
Loading
+30 −4
Original line number Diff line number Diff line
@@ -2,8 +2,18 @@
, stdenvNoCC }:

let
  inherit (lib) hasPrefix hasSuffix removeSuffix;
  escapedList = with lib; concatMapStringsSep " " (s: "'${escape [ "'" ] s}'");
  fileName = pathStr: lib.last (lib.splitString "/" pathStr);
  nameFromPath = pathStr:
    let fN = fileName pathStr; in
    if hasSuffix ".lua" fN then
      fN
    else if !(hasPrefix "." fN) then
      "${fN}.lua"
    else
      null
  ;
  scriptsDir = "$out/share/mpv/scripts";
in
lib.makeOverridable (
@@ -13,8 +23,8 @@ lib.makeOverridable (
  let
    # either passthru.scriptName, inferred from scriptPath, or from pname
    scriptName = (args.passthru or {}).scriptName or (
      if args ? scriptPath
      then fileName args.scriptPath
      if args ? scriptPath && nameFromPath args.scriptPath != null
      then nameFromPath args.scriptPath
      else "${pname}.lua"
    );
    scriptPath = args.scriptPath or "./${scriptName}";
@@ -26,8 +36,24 @@ lib.makeOverridable (
    outputHashMode = "recursive";
    installPhase = ''
      runHook preInstall

      if [ -d "${scriptPath}" ]; then
        [ -f "${scriptPath}/main.lua" ] || {
          echo "Script directory '${scriptPath}' does not contain 'main.lua'" >&2
          exit 1
        }
        [ ${with builtins; toString (length extraScripts)} -eq 0 ] || {
          echo "mpvScripts.buildLua does not support 'extraScripts'" \
               "when 'scriptPath' is a directory"
          exit 1
        }
        mkdir -p "${scriptsDir}"
        cp -a "${scriptPath}" "${scriptsDir}/${lib.removeSuffix ".lua" scriptName}"
      else
        install -m644 -Dt "${scriptsDir}" \
          ${escapedList ([ scriptPath ] ++ extraScripts)}
      fi

      runHook postInstall
    '';

+1 −1
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ in lib.recurseIntoAttrs
    mpv-webm = callPackage ./mpv-webm.nix { };
    mpvacious = callPackage ./mpvacious.nix { inherit buildLua; };
    quality-menu = callPackage ./quality-menu.nix { inherit buildLua; };
    simple-mpv-webui = callPackage ./simple-mpv-webui.nix { };
    simple-mpv-webui = callPackage ./simple-mpv-webui.nix { inherit buildLua; };
    sponsorblock = callPackage ./sponsorblock.nix { };
    thumbfast = callPackage ./thumbfast.nix { inherit buildLua; };
    thumbnail = callPackage ./thumbnail.nix { inherit buildLua; };
+6 −10
Original line number Diff line number Diff line
{ lib, stdenvNoCC
{ lib, buildLua
, fetchFromGitHub }:
stdenvNoCC.mkDerivation rec {
buildLua rec {
  pname = "simple-mpv-ui";
  version = "2.1.0";
  version = "3.0.0";

  src = fetchFromGitHub {
    owner = "open-dynaMIX";
    repo = "simple-mpv-webui";
    rev = "v${version}";
    sha256 = "1z0y8sdv5mbxznxqh43w5592ym688vkvqg7w26p8cinrhf09pbw8";
    hash = "sha256-I8lwpo3Hfpy3UnPMmHEJCdArVQnNL245NkxsYVmnMF0=";
    sparseCheckout = [ "main.lua" "webui-page" ];
  };

  dontBuild = true;
  installPhase = ''
    mkdir -p $out/share/mpv/scripts
    cp -r webui.lua webui-page $out/share/mpv/scripts/
  '';
  scriptPath = ".";
  passthru.scriptName = "webui.lua";

  meta = with lib; {
@@ -30,4 +27,3 @@ stdenvNoCC.mkDerivation rec {
    license = licenses.mit;
  };
}