Skip to content

Commit 95428ba

Browse files
Merge #359866 (mpvScripts: Use lib.packagesFromDirectoryRecursive)
2 parents ed307b9 + e7535d9 commit 95428ba

File tree

5 files changed

+89
-120
lines changed

5 files changed

+89
-120
lines changed

pkgs/applications/video/mpv/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ stdenv.mkDerivation (finalAttrs: {
282282
;
283283

284284
wrapper = callPackage ./wrapper.nix { };
285-
scripts = callPackage ./scripts { };
285+
scripts = callPackage ./scripts.nix { };
286286

287287
tests = {
288288
inherit (nixosTests) mpv;

pkgs/applications/video/mpv/scripts/default.nix renamed to pkgs/applications/video/mpv/scripts.nix

Lines changed: 26 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -82,69 +82,31 @@ let
8282

8383
scope =
8484
self:
85-
let
86-
inherit (self) callPackage;
87-
in
88-
lib.mapAttrsRecursiveCond (x: x.recurseForDerivations or false) addTests (
89-
lib.recurseIntoAttrs {
90-
inherit (callPackage ./mpv.nix { })
91-
acompressor
92-
autocrop
93-
autodeint
94-
autoload
95-
;
96-
inherit (callPackage ./occivink.nix { })
97-
blacklistExtensions
98-
crop
99-
encode
100-
seekTo
101-
;
102-
103-
buildLua = callPackage ./buildLua.nix { };
104-
autosub = callPackage ./autosub.nix { };
105-
autosubsync-mpv = callPackage ./autosubsync-mpv.nix { };
106-
chapterskip = callPackage ./chapterskip.nix { };
107-
convert = callPackage ./convert.nix { };
108-
cutter = callPackage ./cutter.nix { };
109-
dynamic-crop = callPackage ./dynamic-crop.nix { };
110-
evafast = callPackage ./evafast.nix { };
111-
inhibit-gnome = callPackage ./inhibit-gnome.nix { };
112-
memo = callPackage ./memo.nix { };
113-
manga-reader = callPackage ./manga-reader.nix { };
114-
modernx = callPackage ./modernx.nix { };
115-
modernx-zydezu = callPackage ./modernx-zydezu.nix { };
116-
mpris = callPackage ./mpris.nix { };
117-
mpv-cheatsheet = callPackage ./mpv-cheatsheet.nix { };
118-
mpv-discord = callPackage ./mpv-discord.nix { };
119-
mpv-notify-send = callPackage ./mpv-notify-send.nix { };
120-
mpv-osc-modern = callPackage ./mpv-osc-modern.nix { };
121-
mpv-osc-tethys = callPackage ./mpv-osc-tethys.nix { };
122-
mpv-playlistmanager = callPackage ./mpv-playlistmanager.nix { };
123-
mpv-slicing = callPackage ./mpv-slicing.nix { };
124-
mpv-subtitle-lines = callPackage ./mpv-subtitle-lines.nix { };
125-
mpv-webm = callPackage ./mpv-webm.nix { };
126-
mpvacious = callPackage ./mpvacious.nix { };
127-
quack = callPackage ./quack.nix { };
128-
quality-menu = callPackage ./quality-menu.nix { };
129-
reload = callPackage ./reload.nix { };
130-
simple-mpv-webui = callPackage ./simple-mpv-webui.nix { };
131-
smart-copy-paste-2 = callPackage ./smart-copy-paste-2.nix { };
132-
smartskip = callPackage ./smartskip.nix { };
133-
sponsorblock = callPackage ./sponsorblock.nix { };
134-
sponsorblock-minimal = callPackage ./sponsorblock-minimal.nix { };
135-
thumbfast = callPackage ./thumbfast.nix { };
136-
thumbnail = callPackage ./thumbnail.nix { };
137-
uosc = callPackage ./uosc.nix { };
138-
videoclip = callPackage ./videoclip.nix { };
139-
visualizer = callPackage ./visualizer.nix { };
140-
vr-reversal = callPackage ./vr-reversal.nix { };
141-
webtorrent-mpv-hook = callPackage ./webtorrent-mpv-hook.nix { };
142-
youtube-chat = callPackage ./youtube-chat.nix { };
143-
youtube-upnext = callPackage ./youtube-upnext.nix { };
85+
with lib;
86+
pipe
87+
{
88+
inherit (self) callPackage;
89+
directory = ./scripts;
14490
}
145-
);
91+
[
92+
packagesFromDirectoryRecursive
93+
recurseIntoAttrs
94+
(mapAttrsRecursiveCond (x: x.recurseForDerivations or false) addTests)
95+
];
14696

147-
aliases = {
97+
mkAliases = self: {
98+
inherit (self.builtins)
99+
acompressor
100+
autocrop
101+
autodeint
102+
autoload
103+
; # added 2024-11-28
104+
inherit (self.occivink)
105+
blacklistExtensions
106+
crop
107+
encode
108+
seekTo
109+
; # added 2024-11-28
148110
youtube-quality = throw "'youtube-quality' is no longer maintained, use 'quality-menu' instead"; # added 2023-07-14
149111
};
150112
in
@@ -153,6 +115,9 @@ lib.pipe scope [
153115
(lib.makeScope newScope)
154116
(
155117
self:
118+
let
119+
aliases = mkAliases self;
120+
in
156121
assert builtins.intersectAttrs self aliases == { };
157122
self // lib.optionalAttrs config.allowAliases aliases
158123
)
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
lib,
3+
buildLua,
4+
mpv-unwrapped,
5+
}:
6+
7+
let
8+
mkBuiltin =
9+
name: args:
10+
let
11+
srcPath = "TOOLS/lua/${name}.lua";
12+
in
13+
buildLua (
14+
lib.attrsets.recursiveUpdate rec {
15+
inherit (mpv-unwrapped) src version;
16+
pname = "mpv-${name}";
17+
18+
dontUnpack = true;
19+
scriptPath = "${src}/${srcPath}";
20+
21+
meta = with lib; {
22+
inherit (mpv-unwrapped.meta) license;
23+
homepage = "https://github.com/mpv-player/mpv/blob/v${version}/${srcPath}";
24+
};
25+
} args
26+
);
27+
in
28+
lib.recurseIntoAttrs (
29+
lib.mapAttrs (name: lib.makeOverridable (mkBuiltin name)) {
30+
acompressor.meta = {
31+
description = "Script to toggle and control ffmpeg's dynamic range compression filter";
32+
maintainers = with lib.maintainers; [ nicoo ];
33+
};
34+
35+
autocrop.meta.description = "This script uses the lavfi cropdetect filter to automatically insert a crop filter with appropriate parameters for the currently playing video";
36+
37+
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";
38+
39+
autoload.meta = {
40+
description = "This script automatically loads playlist entries before and after the currently played file";
41+
maintainers = [ lib.maintainers.dawidsowa ];
42+
};
43+
}
44+
)

pkgs/applications/video/mpv/scripts/mpv.nix

Lines changed: 0 additions & 42 deletions
This file was deleted.

pkgs/applications/video/mpv/scripts/occivink.nix

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,21 @@ let
4242
in
4343
buildLua (lib.attrsets.recursiveUpdate self args);
4444
in
45-
lib.mapAttrs (name: lib.makeOverridable (mkScript name)) {
46-
47-
# Usage: `pkgs.mpv.override { scripts = [ pkgs.mpvScripts.seekTo ]; }`
48-
crop.meta.description = "Crop the current video in a visual manner";
49-
seekTo.meta.description = "Mpv script for seeking to a specific position";
50-
blacklistExtensions.meta.description = "Automatically remove playlist entries based on their extension";
51-
52-
encode = {
53-
meta.description = "Make an extract of the video currently playing using ffmpeg";
54-
55-
postPatch = ''
56-
substituteInPlace scripts/encode.lua \
57-
--replace-fail '"ffmpeg"' '"${lib.getExe ffmpeg}"'
58-
'';
59-
};
60-
}
45+
lib.recurseIntoAttrs (
46+
lib.mapAttrs (name: lib.makeOverridable (mkScript name)) {
47+
48+
# Usage: `pkgs.mpv.override { scripts = [ pkgs.mpvScripts.seekTo ]; }`
49+
crop.meta.description = "Crop the current video in a visual manner";
50+
seekTo.meta.description = "Mpv script for seeking to a specific position";
51+
blacklistExtensions.meta.description = "Automatically remove playlist entries based on their extension";
52+
53+
encode = {
54+
meta.description = "Make an extract of the video currently playing using ffmpeg";
55+
56+
postPatch = ''
57+
substituteInPlace scripts/encode.lua \
58+
--replace-fail '"ffmpeg"' '"${lib.getExe ffmpeg}"'
59+
'';
60+
};
61+
}
62+
)

0 commit comments

Comments
 (0)