From 1bca51002363052af0c52e5867494c583476b87c Mon Sep 17 00:00:00 2001 From: nicoo Date: Thu, 28 Nov 2024 15:04:29 +0000 Subject: [PATCH 1/2] mpvScripts: Use `lib.packagesFromDirectoryRecursive` As a side-effect, scripts built from the same repo are now grouped into attrsets. Aliases for the current scripts were added. --- pkgs/applications/video/mpv/default.nix | 2 +- .../mpv/{scripts/default.nix => scripts.nix} | 87 ++++++------------- pkgs/applications/video/mpv/scripts/mpv.nix | 26 +++--- .../video/mpv/scripts/occivink.nix | 28 +++--- 4 files changed, 56 insertions(+), 87 deletions(-) rename pkgs/applications/video/mpv/{scripts/default.nix => scripts.nix} (51%) diff --git a/pkgs/applications/video/mpv/default.nix b/pkgs/applications/video/mpv/default.nix index 30a3fa8be994..e66f19778605 100644 --- a/pkgs/applications/video/mpv/default.nix +++ b/pkgs/applications/video/mpv/default.nix @@ -282,7 +282,7 @@ stdenv.mkDerivation (finalAttrs: { ; wrapper = callPackage ./wrapper.nix { }; - scripts = callPackage ./scripts { }; + scripts = callPackage ./scripts.nix { }; tests = { inherit (nixosTests) mpv; diff --git a/pkgs/applications/video/mpv/scripts/default.nix b/pkgs/applications/video/mpv/scripts.nix similarity index 51% rename from pkgs/applications/video/mpv/scripts/default.nix rename to pkgs/applications/video/mpv/scripts.nix index 5e3d3aa4e3ab..06df10beecd5 100644 --- a/pkgs/applications/video/mpv/scripts/default.nix +++ b/pkgs/applications/video/mpv/scripts.nix @@ -82,69 +82,31 @@ let scope = self: - let - inherit (self) callPackage; - in - lib.mapAttrsRecursiveCond (x: x.recurseForDerivations or false) addTests ( - lib.recurseIntoAttrs { - inherit (callPackage ./mpv.nix { }) - acompressor - autocrop - autodeint - autoload - ; - inherit (callPackage ./occivink.nix { }) - blacklistExtensions - crop - encode - seekTo - ; - - buildLua = callPackage ./buildLua.nix { }; - autosub = callPackage ./autosub.nix { }; - autosubsync-mpv = callPackage ./autosubsync-mpv.nix { }; - chapterskip = callPackage ./chapterskip.nix { }; - convert = callPackage ./convert.nix { }; - cutter = callPackage ./cutter.nix { }; - dynamic-crop = callPackage ./dynamic-crop.nix { }; - evafast = callPackage ./evafast.nix { }; - inhibit-gnome = callPackage ./inhibit-gnome.nix { }; - memo = callPackage ./memo.nix { }; - manga-reader = callPackage ./manga-reader.nix { }; - modernx = callPackage ./modernx.nix { }; - modernx-zydezu = callPackage ./modernx-zydezu.nix { }; - mpris = callPackage ./mpris.nix { }; - mpv-cheatsheet = callPackage ./mpv-cheatsheet.nix { }; - mpv-discord = callPackage ./mpv-discord.nix { }; - mpv-notify-send = callPackage ./mpv-notify-send.nix { }; - mpv-osc-modern = callPackage ./mpv-osc-modern.nix { }; - mpv-osc-tethys = callPackage ./mpv-osc-tethys.nix { }; - mpv-playlistmanager = callPackage ./mpv-playlistmanager.nix { }; - mpv-slicing = callPackage ./mpv-slicing.nix { }; - mpv-subtitle-lines = callPackage ./mpv-subtitle-lines.nix { }; - mpv-webm = callPackage ./mpv-webm.nix { }; - mpvacious = callPackage ./mpvacious.nix { }; - quack = callPackage ./quack.nix { }; - quality-menu = callPackage ./quality-menu.nix { }; - reload = callPackage ./reload.nix { }; - simple-mpv-webui = callPackage ./simple-mpv-webui.nix { }; - smart-copy-paste-2 = callPackage ./smart-copy-paste-2.nix { }; - smartskip = callPackage ./smartskip.nix { }; - sponsorblock = callPackage ./sponsorblock.nix { }; - sponsorblock-minimal = callPackage ./sponsorblock-minimal.nix { }; - thumbfast = callPackage ./thumbfast.nix { }; - thumbnail = callPackage ./thumbnail.nix { }; - uosc = callPackage ./uosc.nix { }; - videoclip = callPackage ./videoclip.nix { }; - visualizer = callPackage ./visualizer.nix { }; - vr-reversal = callPackage ./vr-reversal.nix { }; - webtorrent-mpv-hook = callPackage ./webtorrent-mpv-hook.nix { }; - youtube-chat = callPackage ./youtube-chat.nix { }; - youtube-upnext = callPackage ./youtube-upnext.nix { }; + with lib; + pipe + { + inherit (self) callPackage; + directory = ./scripts; } - ); + [ + packagesFromDirectoryRecursive + recurseIntoAttrs + (mapAttrsRecursiveCond (x: x.recurseForDerivations or false) addTests) + ]; - aliases = { + mkAliases = self: { + inherit (self.mpv) + acompressor + autocrop + autodeint + autoload + ; # added 2024-11-28 + inherit (self.occivink) + blacklistExtensions + crop + encode + seekTo + ; # added 2024-11-28 youtube-quality = throw "'youtube-quality' is no longer maintained, use 'quality-menu' instead"; # added 2023-07-14 }; in @@ -153,6 +115,9 @@ lib.pipe scope [ (lib.makeScope newScope) ( self: + let + aliases = mkAliases self; + in assert builtins.intersectAttrs self aliases == { }; self // lib.optionalAttrs config.allowAliases aliases ) diff --git a/pkgs/applications/video/mpv/scripts/mpv.nix b/pkgs/applications/video/mpv/scripts/mpv.nix index a81ac77686d5..5e0af3403fb2 100644 --- a/pkgs/applications/video/mpv/scripts/mpv.nix +++ b/pkgs/applications/video/mpv/scripts/mpv.nix @@ -25,18 +25,20 @@ let } args ); in -lib.mapAttrs (name: lib.makeOverridable (mkBuiltin name)) { - acompressor.meta = { - description = "Script to toggle and control ffmpeg's dynamic range compression filter"; - maintainers = with lib.maintainers; [ nicoo ]; - }; +lib.recurseIntoAttrs ( + lib.mapAttrs (name: lib.makeOverridable (mkBuiltin name)) { + acompressor.meta = { + description = "Script to toggle and control ffmpeg's dynamic range compression filter"; + maintainers = with lib.maintainers; [ nicoo ]; + }; - autocrop.meta.description = "This script uses the lavfi cropdetect filter to automatically insert a crop filter with appropriate parameters for the currently playing video"; + autocrop.meta.description = "This script uses the lavfi cropdetect filter to automatically insert a crop filter with appropriate parameters for the currently playing video"; - autodeint.meta.description = "This script uses the lavfi idet filter to automatically insert the appropriate deinterlacing filter based on a short section of the currently playing video"; + autodeint.meta.description = "This script uses the lavfi idet filter to automatically insert the appropriate deinterlacing filter based on a short section of the currently playing video"; - autoload.meta = { - description = "This script automatically loads playlist entries before and after the currently played file"; - maintainers = [ lib.maintainers.dawidsowa ]; - }; -} + autoload.meta = { + description = "This script automatically loads playlist entries before and after the currently played file"; + maintainers = [ lib.maintainers.dawidsowa ]; + }; + } +) diff --git a/pkgs/applications/video/mpv/scripts/occivink.nix b/pkgs/applications/video/mpv/scripts/occivink.nix index f9fe912a612f..cadb4933e9b5 100644 --- a/pkgs/applications/video/mpv/scripts/occivink.nix +++ b/pkgs/applications/video/mpv/scripts/occivink.nix @@ -42,19 +42,21 @@ let in buildLua (lib.attrsets.recursiveUpdate self args); in -lib.mapAttrs (name: lib.makeOverridable (mkScript name)) { +lib.recurseIntoAttrs ( + lib.mapAttrs (name: lib.makeOverridable (mkScript name)) { - # Usage: `pkgs.mpv.override { scripts = [ pkgs.mpvScripts.seekTo ]; }` - crop.meta.description = "Crop the current video in a visual manner"; - seekTo.meta.description = "Mpv script for seeking to a specific position"; - blacklistExtensions.meta.description = "Automatically remove playlist entries based on their extension"; + # Usage: `pkgs.mpv.override { scripts = [ pkgs.mpvScripts.seekTo ]; }` + crop.meta.description = "Crop the current video in a visual manner"; + seekTo.meta.description = "Mpv script for seeking to a specific position"; + blacklistExtensions.meta.description = "Automatically remove playlist entries based on their extension"; - encode = { - meta.description = "Make an extract of the video currently playing using ffmpeg"; + encode = { + meta.description = "Make an extract of the video currently playing using ffmpeg"; - postPatch = '' - substituteInPlace scripts/encode.lua \ - --replace-fail '"ffmpeg"' '"${lib.getExe ffmpeg}"' - ''; - }; -} + postPatch = '' + substituteInPlace scripts/encode.lua \ + --replace-fail '"ffmpeg"' '"${lib.getExe ffmpeg}"' + ''; + }; + } +) From e7535d9bc9b06377cfb61ba937246a7c5c3a3884 Mon Sep 17 00:00:00 2001 From: nicoo Date: Thu, 28 Nov 2024 15:05:43 +0000 Subject: [PATCH 2/2] =?UTF-8?q?mpvScripts:=20mpv=20=E2=86=92=20builtins?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkgs/applications/video/mpv/scripts.nix | 2 +- pkgs/applications/video/mpv/scripts/{mpv.nix => builtins.nix} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename pkgs/applications/video/mpv/scripts/{mpv.nix => builtins.nix} (100%) diff --git a/pkgs/applications/video/mpv/scripts.nix b/pkgs/applications/video/mpv/scripts.nix index 06df10beecd5..151674c8a958 100644 --- a/pkgs/applications/video/mpv/scripts.nix +++ b/pkgs/applications/video/mpv/scripts.nix @@ -95,7 +95,7 @@ let ]; mkAliases = self: { - inherit (self.mpv) + inherit (self.builtins) acompressor autocrop autodeint diff --git a/pkgs/applications/video/mpv/scripts/mpv.nix b/pkgs/applications/video/mpv/scripts/builtins.nix similarity index 100% rename from pkgs/applications/video/mpv/scripts/mpv.nix rename to pkgs/applications/video/mpv/scripts/builtins.nix