mpvScripts.{blacklistExtensions, seekTo}: makeOverridable & refactor

nicoo 54d25073 a899b23b

+11 -7
+11 -7
pkgs/applications/video/mpv/scripts/occivink.nix
··· 4 }: 5 6 let 7 - script = { pname, ...}@args: 8 - buildLua (lib.attrsets.recursiveUpdate { 9 src = fetchFromGitHub { 10 owner = "occivink"; 11 repo = "mpv-scripts"; ··· 24 } args); 25 26 in 27 - { 28 29 # Usage: `pkgs.mpv.override { scripts = [ pkgs.mpvScripts.seekTo ]; }` 30 - seekTo = script { 31 - pname = "seek-to"; 32 meta.description = "Mpv script for seeking to a specific position"; 33 outputHash = "sha256-3RlbtUivmeoR9TZ6rABiZSd5jd2lFv/8p/4irHMLshs="; 34 }; 35 36 - blacklistExtensions = script { 37 - pname = "blacklist-extensions"; 38 meta.description = "Automatically remove playlist entries based on their extension."; 39 outputHash = "sha256-qw9lz8ofmvvh23F9aWLxiU4YofY+YflRETu+nxMhvVE="; 40 };
··· 4 }: 5 6 let 7 + camelToKebab = let 8 + inherit (lib.strings) match stringAsChars toLower; 9 + isUpper = match "[A-Z]"; 10 + in stringAsChars (c: if isUpper c != null then "-${toLower c}" else c); 11 + 12 + mkScript = name: args: 13 + buildLua (lib.attrsets.recursiveUpdate rec { 14 + pname = camelToKebab name; 15 src = fetchFromGitHub { 16 owner = "occivink"; 17 repo = "mpv-scripts"; ··· 30 } args); 31 32 in 33 + lib.mapAttrs (name: lib.makeOverridable (mkScript name)) { 34 35 # Usage: `pkgs.mpv.override { scripts = [ pkgs.mpvScripts.seekTo ]; }` 36 + seekTo = { 37 meta.description = "Mpv script for seeking to a specific position"; 38 outputHash = "sha256-3RlbtUivmeoR9TZ6rABiZSd5jd2lFv/8p/4irHMLshs="; 39 }; 40 41 + blacklistExtensions = { 42 meta.description = "Automatically remove playlist entries based on their extension."; 43 outputHash = "sha256-qw9lz8ofmvvh23F9aWLxiU4YofY+YflRETu+nxMhvVE="; 44 };