Merge pull request #270962 from nbraud/mpvScripts/uosc

mpvScripts.uosc: 4.7.0 → 5.1.1
This commit is contained in:
Maciej Krüger 2023-12-09 22:19:44 +01:00 committed by GitHub
commit 81d9c2772e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 37 deletions

View file

@ -5,31 +5,29 @@ 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";
# similar to `lib.extends`, but with inverted precedence and recursive update
extendedBy = args: orig: self:
let super = args self;
in lib.recursiveUpdate (orig super) super
;
in
lib.makeOverridable (
lib.makeOverridable (args: stdenvNoCC.mkDerivation (extendedBy
(if lib.isFunction args then args else (_: args)) (
{ pname
, extraScripts ? []
, ... }@args:
let
# either passthru.scriptName, inferred from scriptPath, or from pname
scriptName = (args.passthru or {}).scriptName or (
if args ? scriptPath && nameFromPath args.scriptPath != null
then nameFromPath args.scriptPath
if args ? scriptPath
then fileName args.scriptPath
else "${pname}.lua"
);
scriptPath = args.scriptPath or "./${scriptName}";
in
stdenvNoCC.mkDerivation (lib.attrsets.recursiveUpdate {
in {
dontBuild = true;
preferLocalBuild = true;
@ -59,5 +57,5 @@ lib.makeOverridable (
passthru = { inherit scriptName; };
meta.platforms = lib.platforms.all;
} args)
)
})
))

View file

@ -22,7 +22,7 @@ in lib.recurseIntoAttrs
sponsorblock = callPackage ./sponsorblock.nix { };
thumbfast = callPackage ./thumbfast.nix { inherit buildLua; };
thumbnail = callPackage ./thumbnail.nix { inherit buildLua; };
uosc = callPackage ./uosc.nix { };
uosc = callPackage ./uosc.nix { inherit buildLua; };
visualizer = callPackage ./visualizer.nix { };
vr-reversal = callPackage ./vr-reversal.nix { };
webtorrent-mpv-hook = callPackage ./webtorrent-mpv-hook.nix { };

View file

@ -1,42 +1,50 @@
{ stdenvNoCC, lib, fetchFromGitHub, makeFontsConf }:
{ lib
, fetchFromGitHub
, fetchpatch
, makeFontsConf
, buildLua
, buildGoModule
}:
stdenvNoCC.mkDerivation (finalAttrs: {
buildLua (finalAttrs: {
pname = "uosc";
version = "4.7.0";
version = "5.1.1";
scriptPath = "src/uosc";
src = fetchFromGitHub {
owner = "tomasklaen";
repo = "uosc";
rev = finalAttrs.version;
hash = "sha256-JqlBjhwRgmXl6XfHYTwtNWZj656EDHjcdWOlCgihF5I=";
hash = "sha256-+4k8T1yX3IRXK3XkUShsuJSH9w1Zla7CaRENcIqX4iM=";
};
postPatch = ''
substituteInPlace scripts/uosc.lua \
--replace "mp.find_config_file('scripts')" "\"$out/share/mpv/scripts\""
'';
tools = buildGoModule {
pname = "uosc-bin";
inherit (finalAttrs) version src;
vendorHash = "sha256-nkY0z2GiDxfNs98dpe+wZNI3dAXcuHaD/nHiZ2XnZ1Y=";
};
dontBuild = true;
# Patch lua script to get the path to its `ziggy` binary form the environment
patches = [
# uosc#814: Support overriding `ziggy_path` via environment variable
(fetchpatch {
url = "https://github.com/tomasklaen/uosc/commit/4fdf68a1bcb510824d66f35ecc7672a6452a44b2.patch";
hash = "sha256-igUqFf8e7LVIIjGxACdIWAeZxjF/yqaCL4QRXrzNQXk=";
})
];
installPhase = ''
runHook preInstall
mkdir -p $out/share/mpv/
cp -r scripts $out/share/mpv
cp -r fonts $out/share
runHook postInstall
'';
passthru.scriptName = "uosc.lua";
# the script uses custom "texture" fonts as the background for ui elements.
# In order for mpv to find them, we need to adjust the fontconfig search path.
postInstall = "cp -r src/fonts $out/share";
passthru.extraWrapperArgs = [
"--set"
"FONTCONFIG_FILE"
(toString (makeFontsConf {
fontDirectories = [ "${finalAttrs.finalPackage}/share/fonts" ];
}))
"--set"
"MPV_UOSC_ZIGGY"
(lib.getExe' finalAttrs.tools "ziggy")
];
meta = with lib; {