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.
This commit is contained in:
nicoo 2024-11-28 15:04:29 +00:00
parent 595e00cbca
commit 1bca510023
4 changed files with 56 additions and 87 deletions

View File

@ -282,7 +282,7 @@ stdenv.mkDerivation (finalAttrs: {
;
wrapper = callPackage ./wrapper.nix { };
scripts = callPackage ./scripts { };
scripts = callPackage ./scripts.nix { };
tests = {
inherit (nixosTests) mpv;

View File

@ -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
)

View File

@ -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 ];
};
}
)

View File

@ -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}"'
'';
};
}
)