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..151674c8a958 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.builtins) + 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/builtins.nix b/pkgs/applications/video/mpv/scripts/builtins.nix new file mode 100644 index 000000000000..5e0af3403fb2 --- /dev/null +++ b/pkgs/applications/video/mpv/scripts/builtins.nix @@ -0,0 +1,44 @@ +{ + lib, + buildLua, + mpv-unwrapped, +}: + +let + mkBuiltin = + name: args: + let + srcPath = "TOOLS/lua/${name}.lua"; + in + buildLua ( + lib.attrsets.recursiveUpdate rec { + inherit (mpv-unwrapped) src version; + pname = "mpv-${name}"; + + dontUnpack = true; + scriptPath = "${src}/${srcPath}"; + + meta = with lib; { + inherit (mpv-unwrapped.meta) license; + homepage = "https://github.com/mpv-player/mpv/blob/v${version}/${srcPath}"; + }; + } args + ); +in +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"; + + 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 ]; + }; + } +) diff --git a/pkgs/applications/video/mpv/scripts/mpv.nix b/pkgs/applications/video/mpv/scripts/mpv.nix deleted file mode 100644 index a81ac77686d5..000000000000 --- a/pkgs/applications/video/mpv/scripts/mpv.nix +++ /dev/null @@ -1,42 +0,0 @@ -{ - lib, - buildLua, - mpv-unwrapped, -}: - -let - mkBuiltin = - name: args: - let - srcPath = "TOOLS/lua/${name}.lua"; - in - buildLua ( - lib.attrsets.recursiveUpdate rec { - inherit (mpv-unwrapped) src version; - pname = "mpv-${name}"; - - dontUnpack = true; - scriptPath = "${src}/${srcPath}"; - - meta = with lib; { - inherit (mpv-unwrapped.meta) license; - homepage = "https://github.com/mpv-player/mpv/blob/v${version}/${srcPath}"; - }; - } 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 ]; - }; - - 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"; - - 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}"' + ''; + }; + } +)