Merge pull request #270962 from nbraud/mpvScripts/uosc

mpvScripts.uosc: 4.7.0 → 5.1.1

authored by Maciej Krüger and committed by GitHub 81d9c277 d4999df2

+43 -37
+14 -16
pkgs/applications/video/mpv/scripts/buildLua.nix
··· 5 5 inherit (lib) hasPrefix hasSuffix removeSuffix; 6 6 escapedList = with lib; concatMapStringsSep " " (s: "'${escape [ "'" ] s}'"); 7 7 fileName = pathStr: lib.last (lib.splitString "/" pathStr); 8 - nameFromPath = pathStr: 9 - let fN = fileName pathStr; in 10 - if hasSuffix ".lua" fN then 11 - fN 12 - else if !(hasPrefix "." fN) then 13 - "${fN}.lua" 14 - else 15 - null 16 - ; 17 8 scriptsDir = "$out/share/mpv/scripts"; 9 + 10 + # similar to `lib.extends`, but with inverted precedence and recursive update 11 + extendedBy = args: orig: self: 12 + let super = args self; 13 + in lib.recursiveUpdate (orig super) super 14 + ; 18 15 in 19 - lib.makeOverridable ( 16 + 17 + lib.makeOverridable (args: stdenvNoCC.mkDerivation (extendedBy 18 + (if lib.isFunction args then args else (_: args)) ( 20 19 { pname 21 20 , extraScripts ? [] 22 21 , ... }@args: 23 22 let 24 23 # either passthru.scriptName, inferred from scriptPath, or from pname 25 24 scriptName = (args.passthru or {}).scriptName or ( 26 - if args ? scriptPath && nameFromPath args.scriptPath != null 27 - then nameFromPath args.scriptPath 25 + if args ? scriptPath 26 + then fileName args.scriptPath 28 27 else "${pname}.lua" 29 28 ); 30 29 scriptPath = args.scriptPath or "./${scriptName}"; 31 - in 32 - stdenvNoCC.mkDerivation (lib.attrsets.recursiveUpdate { 30 + in { 33 31 dontBuild = true; 34 32 preferLocalBuild = true; 35 33 ··· 59 57 60 58 passthru = { inherit scriptName; }; 61 59 meta.platforms = lib.platforms.all; 62 - } args) 63 - ) 60 + }) 61 + ))
+1 -1
pkgs/applications/video/mpv/scripts/default.nix
··· 22 22 sponsorblock = callPackage ./sponsorblock.nix { }; 23 23 thumbfast = callPackage ./thumbfast.nix { inherit buildLua; }; 24 24 thumbnail = callPackage ./thumbnail.nix { inherit buildLua; }; 25 - uosc = callPackage ./uosc.nix { }; 25 + uosc = callPackage ./uosc.nix { inherit buildLua; }; 26 26 visualizer = callPackage ./visualizer.nix { }; 27 27 vr-reversal = callPackage ./vr-reversal.nix { }; 28 28 webtorrent-mpv-hook = callPackage ./webtorrent-mpv-hook.nix { };
+28 -20
pkgs/applications/video/mpv/scripts/uosc.nix
··· 1 - { stdenvNoCC, lib, fetchFromGitHub, makeFontsConf }: 1 + { lib 2 + , fetchFromGitHub 3 + , fetchpatch 4 + , makeFontsConf 5 + , buildLua 6 + , buildGoModule 7 + }: 2 8 3 - stdenvNoCC.mkDerivation (finalAttrs: { 9 + buildLua (finalAttrs: { 4 10 pname = "uosc"; 5 - version = "4.7.0"; 11 + version = "5.1.1"; 12 + scriptPath = "src/uosc"; 6 13 7 14 src = fetchFromGitHub { 8 15 owner = "tomasklaen"; 9 16 repo = "uosc"; 10 17 rev = finalAttrs.version; 11 - hash = "sha256-JqlBjhwRgmXl6XfHYTwtNWZj656EDHjcdWOlCgihF5I="; 18 + hash = "sha256-+4k8T1yX3IRXK3XkUShsuJSH9w1Zla7CaRENcIqX4iM="; 12 19 }; 13 20 14 - postPatch = '' 15 - substituteInPlace scripts/uosc.lua \ 16 - --replace "mp.find_config_file('scripts')" "\"$out/share/mpv/scripts\"" 17 - ''; 18 - 19 - dontBuild = true; 20 - 21 - installPhase = '' 22 - runHook preInstall 23 - 24 - mkdir -p $out/share/mpv/ 25 - cp -r scripts $out/share/mpv 26 - cp -r fonts $out/share 21 + tools = buildGoModule { 22 + pname = "uosc-bin"; 23 + inherit (finalAttrs) version src; 24 + vendorHash = "sha256-nkY0z2GiDxfNs98dpe+wZNI3dAXcuHaD/nHiZ2XnZ1Y="; 25 + }; 27 26 28 - runHook postInstall 29 - ''; 27 + # Patch lua script to get the path to its `ziggy` binary form the environment 28 + patches = [ 29 + # uosc#814: Support overriding `ziggy_path` via environment variable 30 + (fetchpatch { 31 + url = "https://github.com/tomasklaen/uosc/commit/4fdf68a1bcb510824d66f35ecc7672a6452a44b2.patch"; 32 + hash = "sha256-igUqFf8e7LVIIjGxACdIWAeZxjF/yqaCL4QRXrzNQXk="; 33 + }) 34 + ]; 30 35 31 - passthru.scriptName = "uosc.lua"; 32 36 # the script uses custom "texture" fonts as the background for ui elements. 33 37 # In order for mpv to find them, we need to adjust the fontconfig search path. 38 + postInstall = "cp -r src/fonts $out/share"; 34 39 passthru.extraWrapperArgs = [ 35 40 "--set" 36 41 "FONTCONFIG_FILE" 37 42 (toString (makeFontsConf { 38 43 fontDirectories = [ "${finalAttrs.finalPackage}/share/fonts" ]; 39 44 })) 45 + "--set" 46 + "MPV_UOSC_ZIGGY" 47 + (lib.getExe' finalAttrs.tools "ziggy") 40 48 ]; 41 49 42 50 meta = with lib; {