From e2596ac22d4211b3c070f9e518d7b4dc087edc9b Mon Sep 17 00:00:00 2001 From: nicoo Date: Sun, 9 Mar 2025 16:36:19 +0000 Subject: [PATCH 1/4] mpvScripts.buildLua: add a `runtime-dependencies` option --- .../video/mpv/scripts/buildLua.nix | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/pkgs/applications/video/mpv/scripts/buildLua.nix b/pkgs/applications/video/mpv/scripts/buildLua.nix index 6d6831c1621b..822950ffc9b7 100644 --- a/pkgs/applications/video/mpv/scripts/buildLua.nix +++ b/pkgs/applications/video/mpv/scripts/buildLua.nix @@ -24,6 +24,7 @@ lib.makeOverridable ( { pname, extraScripts ? [ ], + runtime-dependencies ? [ ], ... }@args: let @@ -75,9 +76,20 @@ lib.makeOverridable ( runHook postInstall ''; - passthru = { - inherit scriptName; - }; + passthru = + { + inherit scriptName; + } + // lib.optionalAttrs (runtime-dependencies != [ ]) { + extraWrapperArgs = + [ + "--prefix" + "PATH" + ":" + ] + ++ (map lib.makeBinPath runtime-dependencies) + ++ args.passthru.extraWrapperArgs or [ ]; + }; meta = { platforms = lib.platforms.all; From e67cceafda6d130a82c11bbaad09bd857352ded0 Mon Sep 17 00:00:00 2001 From: nicoo Date: Sun, 9 Mar 2025 16:59:00 +0000 Subject: [PATCH 2/4] mpvScripts.twitch-chat: refactor using buildLua's `runtime-dependencies` --- pkgs/applications/video/mpv/scripts/twitch-chat.nix | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/pkgs/applications/video/mpv/scripts/twitch-chat.nix b/pkgs/applications/video/mpv/scripts/twitch-chat.nix index 2bce83b95bcf..35f369cf54a2 100644 --- a/pkgs/applications/video/mpv/scripts/twitch-chat.nix +++ b/pkgs/applications/video/mpv/scripts/twitch-chat.nix @@ -22,12 +22,7 @@ buildLua (finalAttrs: { runHook postInstall ''; - passthru.extraWrapperArgs = [ - "--prefix" - "PATH" - ":" - (lib.makeBinPath [ curl ]) - ]; + runtime-dependencies = [ curl ]; passthru.updateScript = nix-update-script { extraArgs = [ "--version=branch" ]; From fc2c0fcab1f8b3d112e6e46fd2c6a447ef6e0cc2 Mon Sep 17 00:00:00 2001 From: nicoo Date: Sun, 9 Mar 2025 15:38:27 +0000 Subject: [PATCH 3/4] mpvScripts.twitch-chat: avoid explicit recursion when unnecessary --- pkgs/applications/video/mpv/scripts/twitch-chat.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/applications/video/mpv/scripts/twitch-chat.nix b/pkgs/applications/video/mpv/scripts/twitch-chat.nix index 35f369cf54a2..16c7bfb6cf74 100644 --- a/pkgs/applications/video/mpv/scripts/twitch-chat.nix +++ b/pkgs/applications/video/mpv/scripts/twitch-chat.nix @@ -5,7 +5,7 @@ lib, nix-update-script, }: -buildLua (finalAttrs: { +buildLua { pname = "twitch-chat"; version = "0-unstable-2024-06-23"; @@ -34,4 +34,4 @@ buildLua (finalAttrs: { license = lib.licenses.mit; maintainers = [ lib.maintainers.naho ]; }; -}) +} From c67998ff3b628a7af48b022081c22957bc1dfc8f Mon Sep 17 00:00:00 2001 From: nicoo Date: Sun, 9 Mar 2025 15:38:53 +0000 Subject: [PATCH 4/4] mpvScripts.twitch-chat: treat script as directory-packaged Removes the screenshot from the source archive, to avoid wasting space in the build cache and in outputs downloaded by end-users. --- pkgs/applications/video/mpv/scripts/twitch-chat.nix | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pkgs/applications/video/mpv/scripts/twitch-chat.nix b/pkgs/applications/video/mpv/scripts/twitch-chat.nix index 16c7bfb6cf74..cdcadf2f9ead 100644 --- a/pkgs/applications/video/mpv/scripts/twitch-chat.nix +++ b/pkgs/applications/video/mpv/scripts/twitch-chat.nix @@ -13,14 +13,12 @@ buildLua { owner = "CrendKing"; repo = "mpv-twitch-chat"; rev = "bb0c2e84675f4f1e0c221c8e1d3516b60242b985"; - hash = "sha256-WyNPUiAs5U/vrjNbAgyqkfoxh9rabLmuZ1zG5uZYxaw="; + hash = "sha256-lnWYcr49koI60Su85OWbcxrARWTfXW2zIvfCZ6c3GtI="; + + postFetch = "rm $out/screenshot.webp"; }; - installPhase = '' - runHook preInstall - install -D main.lua $out/share/mpv/scripts/twitch-chat.lua - runHook postInstall - ''; + scriptPath = "."; runtime-dependencies = [ curl ];