diff options
author | nicoo <nicoo@mur.at> | 2023-10-17 14:52:25 +0000 |
---|---|---|
committer | nicoo <nicoo@mur.at> | 2023-11-05 15:42:46 +0000 |
commit | a899b23bd3e4f6bd6f6d762dd2260952f1d72b9d (patch) | |
tree | 61a7fae848bb4d709550267c5c6f222f22c8a19c /pkgs/applications/video/mpv | |
parent | 3a2389bf79bceb4ae17c07381e0c73474d9f9c88 (diff) | |
download | nixlib-a899b23bd3e4f6bd6f6d762dd2260952f1d72b9d.tar nixlib-a899b23bd3e4f6bd6f6d762dd2260952f1d72b9d.tar.gz nixlib-a899b23bd3e4f6bd6f6d762dd2260952f1d72b9d.tar.bz2 nixlib-a899b23bd3e4f6bd6f6d762dd2260952f1d72b9d.tar.lz nixlib-a899b23bd3e4f6bd6f6d762dd2260952f1d72b9d.tar.xz nixlib-a899b23bd3e4f6bd6f6d762dd2260952f1d72b9d.tar.zst nixlib-a899b23bd3e4f6bd6f6d762dd2260952f1d72b9d.zip |
mpvScripts: refactor around `buildLua` helper
Diffstat (limited to 'pkgs/applications/video/mpv')
-rw-r--r-- | pkgs/applications/video/mpv/scripts/acompressor.nix | 22 | ||||
-rw-r--r-- | pkgs/applications/video/mpv/scripts/buildLua.nix | 18 | ||||
-rw-r--r-- | pkgs/applications/video/mpv/scripts/chapterskip.nix | 19 | ||||
-rw-r--r-- | pkgs/applications/video/mpv/scripts/default.nix | 9 | ||||
-rw-r--r-- | pkgs/applications/video/mpv/scripts/occivink.nix | 26 |
5 files changed, 40 insertions, 54 deletions
diff --git a/pkgs/applications/video/mpv/scripts/acompressor.nix b/pkgs/applications/video/mpv/scripts/acompressor.nix index d10ef5f9df75..d82d12f163e7 100644 --- a/pkgs/applications/video/mpv/scripts/acompressor.nix +++ b/pkgs/applications/video/mpv/scripts/acompressor.nix @@ -1,27 +1,17 @@ -{ 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 ]; }; } diff --git a/pkgs/applications/video/mpv/scripts/buildLua.nix b/pkgs/applications/video/mpv/scripts/buildLua.nix new file mode 100644 index 000000000000..79703d4cf1c4 --- /dev/null +++ b/pkgs/applications/video/mpv/scripts/buildLua.nix @@ -0,0 +1,18 @@ +{ 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 = "install -m644 -Dt $out/share/mpv/scripts ${scriptPath}"; + passthru.scriptName = fileName scriptPath; + + meta.platforms = lib.platforms.all; + } args) +) diff --git a/pkgs/applications/video/mpv/scripts/chapterskip.nix b/pkgs/applications/video/mpv/scripts/chapterskip.nix index c147da8d4598..bffc27bd1eac 100644 --- a/pkgs/applications/video/mpv/scripts/chapterskip.nix +++ b/pkgs/applications/video/mpv/scripts/chapterskip.nix @@ -1,11 +1,9 @@ { 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 ]; }; } diff --git a/pkgs/applications/video/mpv/scripts/default.nix b/pkgs/applications/video/mpv/scripts/default.nix index 2866f80f5652..562e3de1645b 100644 --- a/pkgs/applications/video/mpv/scripts/default.nix +++ b/pkgs/applications/video/mpv/scripts/default.nix @@ -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 } diff --git a/pkgs/applications/video/mpv/scripts/occivink.nix b/pkgs/applications/video/mpv/scripts/occivink.nix index da723fd9102e..e0f07a10db95 100644 --- a/pkgs/applications/video/mpv/scripts/occivink.nix +++ b/pkgs/applications/video/mpv/scripts/occivink.nix @@ -1,14 +1,11 @@ { lib -, stdenvNoCC , fetchFromGitHub +, buildLua }: let - script = { n, ... }@p: - stdenvNoCC.mkDerivation (lib.attrsets.recursiveUpdate { - pname = "mpv_${n}"; - passthru.scriptName = "${n}.lua"; - + script = { pname, ...}@args: + buildLua (lib.attrsets.recursiveUpdate { src = fetchFromGitHub { owner = "occivink"; repo = "mpv-scripts"; @@ -17,37 +14,28 @@ 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 { # Usage: `pkgs.mpv.override { scripts = [ pkgs.mpvScripts.seekTo ]; }` seekTo = script { - n = "seek-to"; + pname = "seek-to"; meta.description = "Mpv script for seeking to a specific position"; outputHash = "sha256-3RlbtUivmeoR9TZ6rABiZSd5jd2lFv/8p/4irHMLshs="; }; blacklistExtensions = script { - n = "blacklist-extensions"; + pname = "blacklist-extensions"; meta.description = "Automatically remove playlist entries based on their extension."; outputHash = "sha256-qw9lz8ofmvvh23F9aWLxiU4YofY+YflRETu+nxMhvVE="; }; - } |