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

Merge pull request #265676 from nbraud/mpvScripts/refactor

parents de7ab5c7 7b792b0b
Loading
Loading
Loading
Loading
+6 −16
Original line number Diff line number Diff line
{ stdenvNoCC
{ lib
, buildLua
, mpv-unwrapped
, lib
}:

stdenvNoCC.mkDerivation rec {
buildLua {
  inherit (mpv-unwrapped) src version;
  pname = "mpv-acompressor";
  version = mpv-unwrapped.version;

  src = "${mpv-unwrapped.src.outPath}/TOOLS/lua/acompressor.lua";

  dontBuild = true;
  dontUnpack = true;

  installPhase = ''
    install -Dm644 ${src} $out/share/mpv/scripts/acompressor.lua
  '';

  passthru.scriptName = "acompressor.lua";
  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";
    license = licenses.gpl2Plus;
    maintainers = with maintainers; [ nicoo ];
  };
}
+22 −0
Original line number Diff line number Diff line
{ lib
, stdenvNoCC }:

let fileName = pathStr: lib.last (lib.splitString "/" pathStr);
in
lib.makeOverridable (
  { pname, scriptPath ? "${pname}.lua", ... }@args:
  stdenvNoCC.mkDerivation (lib.attrsets.recursiveUpdate {
    dontBuild = true;
    preferLocalBuild = true;

    outputHashMode = "recursive";
    installPhase = ''
      runHook preInstall
      install -m644 -Dt $out/share/mpv/scripts ${scriptPath}
      runHook postInstall
    '';

    passthru.scriptName = fileName scriptPath;
    meta.platforms = lib.platforms.all;
  } args)
)
+4 −15
Original line number Diff line number Diff line
{ lib
, fetchFromGitHub
, nix-update-script
, stdenvNoCC }:
, buildLua }:

stdenvNoCC.mkDerivation {
buildLua {
  pname = "chapterskip";
  passthru.scriptName = "chapterskip.lua";

  version = "unstable-2022-09-08";
  src = fetchFromGitHub {
@@ -15,17 +13,8 @@ stdenvNoCC.mkDerivation {
    hash  = "sha256-OTrLQE3rYvPQamEX23D6HttNjx3vafWdTMxTiWpDy90=";
  };

  dontBuild = true;
  preferLocalBuild = true;
  installPhase = "install -Dt $out/share/mpv/scripts chapterskip.lua";

  passthru.updateScript = nix-update-script {
    extraArgs = [ "--version=branch" ];
  };

  meta = with lib; {
  meta = {
    homepage = "https://github.com/po5/chapterskip";
    platforms = platforms.all;
    maintainers = with maintainers; [ nicoo ];
    maintainers = with lib.maintainers; [ nicoo ];
  };
}
+5 −4
Original line number Diff line number Diff line
@@ -3,13 +3,14 @@
, config
}:

lib.recurseIntoAttrs
let buildLua = callPackage ./buildLua.nix { };
in lib.recurseIntoAttrs
  ({
    acompressor = callPackage ./acompressor.nix { };
    acompressor = callPackage ./acompressor.nix { inherit buildLua; };
    autocrop = callPackage ./autocrop.nix { };
    autodeint = callPackage ./autodeint.nix { };
    autoload = callPackage ./autoload.nix { };
    chapterskip = callPackage ./chapterskip.nix { };
    chapterskip = callPackage ./chapterskip.nix { inherit buildLua; };
    convert = callPackage ./convert.nix { };
    inhibit-gnome = callPackage ./inhibit-gnome.nix { };
    mpris = callPackage ./mpris.nix { };
@@ -27,7 +28,7 @@ lib.recurseIntoAttrs
    webtorrent-mpv-hook = callPackage ./webtorrent-mpv-hook.nix { };
    cutter = callPackage ./cutter.nix { };
  }
  // (callPackage ./occivink.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
}
+14 −22
Original line number Diff line number Diff line
{ lib
, stdenvNoCC
, fetchFromGitHub
, buildLua
}:

let
  script = { n, ... }@p:
    stdenvNoCC.mkDerivation (lib.attrsets.recursiveUpdate {
      pname = "mpv_${n}";
      passthru.scriptName = "${n}.lua";

  camelToKebab = let
    inherit (lib.strings) match stringAsChars toLower;
    isUpper = match "[A-Z]";
  in stringAsChars (c: if isUpper c != null then "-${toLower c}" else c);

  mkScript = name: args:
    buildLua (lib.attrsets.recursiveUpdate rec {
      pname = camelToKebab name;
      src = fetchFromGitHub {
        owner = "occivink";
        repo = "mpv-scripts";
@@ -17,37 +20,26 @@ let
      };
      version = "unstable-2022-10-02";

      dontBuild = true;
      installPhase = ''
        mkdir -p $out/share/mpv/scripts
        cp -r scripts/${n}.lua $out/share/mpv/scripts/
      '';
      scriptPath = "scripts/${pname}.lua";

      meta = with lib; {
        homepage = "https://github.com/occivink/mpv-scripts";
        license = licenses.unlicense;
        platforms = platforms.all;
        maintainers = with maintainers; [ nicoo ];
      };

      outputHashAlgo = "sha256";
      outputHashMode = "recursive";
    } p);
    } args);

in
{
lib.mapAttrs (name: lib.makeOverridable (mkScript name)) {

  # Usage: `pkgs.mpv.override { scripts = [ pkgs.mpvScripts.seekTo ]; }`
  seekTo = script {
    n = "seek-to";
  seekTo = {
    meta.description = "Mpv script for seeking to a specific position";
    outputHash = "sha256-3RlbtUivmeoR9TZ6rABiZSd5jd2lFv/8p/4irHMLshs=";
  };

  blacklistExtensions = script {
    n = "blacklist-extensions";
  blacklistExtensions = {
    meta.description = "Automatically remove playlist entries based on their extension.";
    outputHash = "sha256-qw9lz8ofmvvh23F9aWLxiU4YofY+YflRETu+nxMhvVE=";
  };

}
Loading