Merge pull request #265676 from nbraud/mpvScripts/refactor

authored by Maciej Krüger and committed by GitHub 2a4751dc de7ab5c7

+51 -57
+6 -16
pkgs/applications/video/mpv/scripts/acompressor.nix
··· 1 - { stdenvNoCC 1 + { lib 2 + , buildLua 2 3 , mpv-unwrapped 3 - , lib 4 4 }: 5 5 6 - stdenvNoCC.mkDerivation rec { 6 + buildLua { 7 + inherit (mpv-unwrapped) src version; 7 8 pname = "mpv-acompressor"; 8 - version = mpv-unwrapped.version; 9 - 10 - src = "${mpv-unwrapped.src.outPath}/TOOLS/lua/acompressor.lua"; 11 - 12 - dontBuild = true; 13 - dontUnpack = true; 14 - 15 - installPhase = '' 16 - install -Dm644 ${src} $out/share/mpv/scripts/acompressor.lua 17 - ''; 18 - 19 - passthru.scriptName = "acompressor.lua"; 9 + scriptPath = "TOOLS/lua/acompressor.lua"; 20 10 21 11 meta = with lib; { 12 + inherit (mpv-unwrapped.meta) license; 22 13 description = "Script to toggle and control ffmpeg's dynamic range compression filter."; 23 14 homepage = "https://github.com/mpv-player/mpv/blob/master/TOOLS/lua/acompressor.lua"; 24 - license = licenses.gpl2Plus; 25 15 maintainers = with maintainers; [ nicoo ]; 26 16 }; 27 17 }
+22
pkgs/applications/video/mpv/scripts/buildLua.nix
··· 1 + { lib 2 + , stdenvNoCC }: 3 + 4 + let fileName = pathStr: lib.last (lib.splitString "/" pathStr); 5 + in 6 + lib.makeOverridable ( 7 + { pname, scriptPath ? "${pname}.lua", ... }@args: 8 + stdenvNoCC.mkDerivation (lib.attrsets.recursiveUpdate { 9 + dontBuild = true; 10 + preferLocalBuild = true; 11 + 12 + outputHashMode = "recursive"; 13 + installPhase = '' 14 + runHook preInstall 15 + install -m644 -Dt $out/share/mpv/scripts ${scriptPath} 16 + runHook postInstall 17 + ''; 18 + 19 + passthru.scriptName = fileName scriptPath; 20 + meta.platforms = lib.platforms.all; 21 + } args) 22 + )
+4 -15
pkgs/applications/video/mpv/scripts/chapterskip.nix
··· 1 1 { lib 2 2 , fetchFromGitHub 3 - , nix-update-script 4 - , stdenvNoCC }: 3 + , buildLua }: 5 4 6 - stdenvNoCC.mkDerivation { 5 + buildLua { 7 6 pname = "chapterskip"; 8 - passthru.scriptName = "chapterskip.lua"; 9 7 10 8 version = "unstable-2022-09-08"; 11 9 src = fetchFromGitHub { ··· 15 13 hash = "sha256-OTrLQE3rYvPQamEX23D6HttNjx3vafWdTMxTiWpDy90="; 16 14 }; 17 15 18 - dontBuild = true; 19 - preferLocalBuild = true; 20 - installPhase = "install -Dt $out/share/mpv/scripts chapterskip.lua"; 21 - 22 - passthru.updateScript = nix-update-script { 23 - extraArgs = [ "--version=branch" ]; 24 - }; 25 - 26 - meta = with lib; { 16 + meta = { 27 17 homepage = "https://github.com/po5/chapterskip"; 28 - platforms = platforms.all; 29 - maintainers = with maintainers; [ nicoo ]; 18 + maintainers = with lib.maintainers; [ nicoo ]; 30 19 }; 31 20 }
+5 -4
pkgs/applications/video/mpv/scripts/default.nix
··· 3 3 , config 4 4 }: 5 5 6 - lib.recurseIntoAttrs 6 + let buildLua = callPackage ./buildLua.nix { }; 7 + in lib.recurseIntoAttrs 7 8 ({ 8 - acompressor = callPackage ./acompressor.nix { }; 9 + acompressor = callPackage ./acompressor.nix { inherit buildLua; }; 9 10 autocrop = callPackage ./autocrop.nix { }; 10 11 autodeint = callPackage ./autodeint.nix { }; 11 12 autoload = callPackage ./autoload.nix { }; 12 - chapterskip = callPackage ./chapterskip.nix { }; 13 + chapterskip = callPackage ./chapterskip.nix { inherit buildLua; }; 13 14 convert = callPackage ./convert.nix { }; 14 15 inhibit-gnome = callPackage ./inhibit-gnome.nix { }; 15 16 mpris = callPackage ./mpris.nix { }; ··· 27 28 webtorrent-mpv-hook = callPackage ./webtorrent-mpv-hook.nix { }; 28 29 cutter = callPackage ./cutter.nix { }; 29 30 } 30 - // (callPackage ./occivink.nix { })) 31 + // (callPackage ./occivink.nix { inherit buildLua; })) 31 32 // lib.optionalAttrs config.allowAliases { 32 33 youtube-quality = throw "'youtube-quality' is no longer maintained, use 'quality-menu' instead"; # added 2023-07-14 33 34 }
+13 -21
pkgs/applications/video/mpv/scripts/occivink.nix
··· 1 1 { lib 2 - , stdenvNoCC 3 2 , fetchFromGitHub 3 + , buildLua 4 4 }: 5 5 6 6 let 7 - script = { n, ... }@p: 8 - stdenvNoCC.mkDerivation (lib.attrsets.recursiveUpdate { 9 - pname = "mpv_${n}"; 10 - passthru.scriptName = "${n}.lua"; 7 + camelToKebab = let 8 + inherit (lib.strings) match stringAsChars toLower; 9 + isUpper = match "[A-Z]"; 10 + in stringAsChars (c: if isUpper c != null then "-${toLower c}" else c); 11 11 12 + mkScript = name: args: 13 + buildLua (lib.attrsets.recursiveUpdate rec { 14 + pname = camelToKebab name; 12 15 src = fetchFromGitHub { 13 16 owner = "occivink"; 14 17 repo = "mpv-scripts"; ··· 17 20 }; 18 21 version = "unstable-2022-10-02"; 19 22 20 - dontBuild = true; 21 - installPhase = '' 22 - mkdir -p $out/share/mpv/scripts 23 - cp -r scripts/${n}.lua $out/share/mpv/scripts/ 24 - ''; 23 + scriptPath = "scripts/${pname}.lua"; 25 24 26 25 meta = with lib; { 27 26 homepage = "https://github.com/occivink/mpv-scripts"; 28 27 license = licenses.unlicense; 29 - platforms = platforms.all; 30 28 maintainers = with maintainers; [ nicoo ]; 31 29 }; 32 - 33 - outputHashAlgo = "sha256"; 34 - outputHashMode = "recursive"; 35 - } p); 30 + } args); 36 31 37 32 in 38 - { 33 + lib.mapAttrs (name: lib.makeOverridable (mkScript name)) { 39 34 40 35 # Usage: `pkgs.mpv.override { scripts = [ pkgs.mpvScripts.seekTo ]; }` 41 - seekTo = script { 42 - n = "seek-to"; 36 + seekTo = { 43 37 meta.description = "Mpv script for seeking to a specific position"; 44 38 outputHash = "sha256-3RlbtUivmeoR9TZ6rABiZSd5jd2lFv/8p/4irHMLshs="; 45 39 }; 46 40 47 - blacklistExtensions = script { 48 - n = "blacklist-extensions"; 41 + blacklistExtensions = { 49 42 meta.description = "Automatically remove playlist entries based on their extension."; 50 43 outputHash = "sha256-qw9lz8ofmvvh23F9aWLxiU4YofY+YflRETu+nxMhvVE="; 51 44 }; 52 - 53 45 }
+1 -1
pkgs/top-level/all-packages.nix
··· 33935 33935 wlroots = wlroots_0_15; 33936 33936 }; 33937 33937 33938 - mpvScripts = import ../applications/video/mpv/scripts { inherit lib callPackage config; }; 33938 + mpvScripts = callPackage ../applications/video/mpv/scripts { }; 33939 33939 33940 33940 open-in-mpv = callPackage ../applications/video/open-in-mpv { }; 33941 33941