This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

tools.mpv: reimplement as a wrapperModule

+104 -121
+71 -1
wrapperModules/flake-module.nix
··· 1 - { ... }: 1 + { self, lib, ... }: 2 2 { 3 3 imports = [ 4 4 ./mpv/default.nix 5 5 ]; 6 + flake.wrapLib.mkWrapper = 7 + argsFun: settings: 8 + let 9 + args = argsFun wrapperLib; 10 + pkgs = args.pkgs; 11 + module = args.module; 12 + 13 + wrapperLib = { 14 + types = { 15 + inherit file; 16 + }; 17 + }; 18 + file = lib.types.submodule ( 19 + { name, config, ... }: 20 + { 21 + options = { 22 + content = lib.mkOption { 23 + type = lib.types.lines; 24 + description = '' 25 + content of file 26 + ''; 27 + }; 28 + path = lib.mkOption { 29 + type = lib.types.path; 30 + description = '' 31 + the path to the file 32 + ''; 33 + default = pkgs.writeText name config.content; 34 + }; 35 + }; 36 + } 37 + ); 38 + eval = lib.evalModules { 39 + modules = [ 40 + module 41 + { 42 + options = { 43 + package = lib.mkOption { 44 + type = lib.types.package; 45 + description = "The base package to use."; 46 + }; 47 + extraPackages = lib.mkOption { 48 + type = lib.types.listOf lib.types.package; 49 + default = [ ]; 50 + }; 51 + flags = lib.mkOption { 52 + type = lib.types.attrsOf lib.types.unspecified; # TODO add list handling 53 + default = { }; 54 + }; 55 + passthru = lib.mkOption { 56 + type = lib.types.attrs; 57 + default = { }; 58 + }; 59 + }; 60 + config = settings; 61 + } 62 + ]; 63 + }; 64 + config = eval.config; 65 + options = eval.options; 66 + in 67 + self.libWithPkgs.${pkgs.system}.makeWrapper config.package { 68 + runtimeInputs = config.extraPackages; 69 + flagSeparator = "="; 70 + flags = config.flags; 71 + passthru = { 72 + inherit options config settings; 73 + } 74 + // config.passthru; 75 + }; 6 76 }
+20 -30
tools/mpv/flake-module.nix
··· 1 1 { self, ... }: 2 2 { 3 3 perSystem = 4 - { pkgs, system, ... }: 4 + { self', pkgs, ... }: 5 5 { 6 6 packages.mpv = 7 7 let 8 - mpvInput = pkgs.writeText "mpv.input" '' 9 - : script-binding console/enable 10 - x add audio-delay -0.050 11 - X add audio-delay 0.050 12 - F script-binding quality_menu/video_formats_toggle 13 - Alt+f script-binding quality_menu/audio_formats_toggle 14 - ''; 15 - 16 - mpvConfig = pkgs.writeText "mpv.conf" '' 17 - osd-font-size=20 18 - ''; 19 - 20 8 # Lazy-loaded autosub script 21 9 autosub = pkgs.writeText "autosub.lua" '' 22 10 utils = require 'mp.utils' ··· 57 45 mp.add_key_binding('S', "download_subs", download) 58 46 ''; 59 47 60 - mpvPackage = pkgs.mpv.override { 61 - scripts = with pkgs.mpvScripts; [ 62 - sponsorblock 63 - quality-menu 64 - vr-reversal 65 - visualizer 66 - ]; 67 - }; 68 - 69 48 in 70 - self.libWithPkgs.${system}.makeWrapper mpvPackage { 71 - runtimeInputs = [ pkgs.yt-dlp ]; 72 - flagSeparator = "="; 73 - flags = { 74 - "--no-config" = { }; 75 - "--input-conf" = "${mpvInput}"; 76 - "--include" = "${mpvConfig}"; 77 - "--script" = "${autosub}"; 49 + self'.legacyPackages.wrappers.mpv { 50 + scripts = with pkgs.mpvScripts; [ 51 + sponsorblock 52 + quality-menu 53 + vr-reversal 54 + visualizer 55 + ]; 56 + extraFlags = { 78 57 "--ytdl-format" = "best[height<1081]"; 79 58 "--script-opts" = "ytdl_hook-ytdl_path=${pkgs.yt-dlp}/bin/yt-dlp"; 80 59 "--script-opts-append" = "sponsorblock-local_database=no"; 81 60 "--audio-channels" = "2"; 61 + "--script" = autosub; 82 62 }; 63 + "mpv.input".content = '' 64 + : script-binding console/enable 65 + x add audio-delay -0.050 66 + X add audio-delay 0.050 67 + F script-binding quality_menu/video_formats_toggle 68 + Alt+f script-binding quality_menu/audio_formats_toggle 69 + ''; 70 + "mpv.conf".content = '' 71 + osd-font-size=20 72 + ''; 83 73 }; 84 74 85 75 # Separate package for subtitle downloader
+13 -90
wrapperModules/mpv/default.nix
··· 5 5 }: 6 6 { 7 7 perSystem = 8 - { pkgs, self', ... }: 8 + { pkgs, ... }: 9 9 { 10 10 legacyPackages.wrappers.mpv = self.wrapLib.mkWrapper (wlib: { 11 11 inherit pkgs; ··· 28 28 osd-font-size=20 29 29 ''; 30 30 }; 31 + extraFlags = lib.mkOption { 32 + type = lib.types.attrsOf lib.types.unspecified; # TODO add list handling 33 + default = { }; 34 + description = "Extra flags to pass to mpv."; 35 + }; 31 36 }; 32 37 config.flags = { 33 38 "--no-config" = { }; 34 39 "--input-conf" = config."mpv.input".path; 35 40 "--include" = config."mpv.conf".path; 36 - "--ytdl-format" = "best[height<1081]"; 37 - "--script-opts" = "ytdl_hook-ytdl_path=${pkgs.yt-dlp}/bin/yt-dlp"; 38 - "--script-opts-append" = "sponsorblock-local_database=no"; 39 - "--audio-channels" = "2"; 40 - "--script" = config.scripts; 41 - }; 41 + } 42 + // config.extraFlags; 43 + config.package = lib.mkDefault ( 44 + pkgs.mpv.override { 45 + scripts = config.scripts; 46 + } 47 + ); 42 48 }; 43 49 }); 44 - packages.mpv_test = self'.legacyPackages.wrappers.mpv { 45 - }; 46 - }; 47 - flake.wrapLib.mkWrapper = 48 - argsFun: settings: 49 - let 50 - args = argsFun wrapperLib; 51 - pkgs = args.pkgs; 52 - module = args.module; 53 - 54 - wrapperLib = { 55 - types = { 56 - inherit file; 57 - }; 58 - }; 59 - file = lib.types.submodule ( 60 - { name, config, ... }: 61 - { 62 - options = { 63 - content = lib.mkOption { 64 - type = lib.types.lines; 65 - description = '' 66 - content of file 67 - ''; 68 - }; 69 - path = lib.mkOption { 70 - type = lib.types.path; 71 - description = '' 72 - the path to the file 73 - ''; 74 - default = pkgs.writeText name config.content; 75 - }; 76 - }; 77 - } 78 - ); 79 - eval = lib.evalModules { 80 - modules = [ 81 - module 82 - { 83 - options = { 84 - package = lib.mkOption { 85 - type = lib.types.package; 86 - default = pkgs.mpv; 87 - description = "The base mpv package to use."; 88 - }; 89 - extraPackages = lib.mkOption { 90 - type = lib.types.listOf lib.types.package; 91 - default = [ ]; 92 - }; 93 - flags = lib.mkOption { 94 - type = lib.types.attrsOf lib.types.unspecified; # TODO add list handling 95 - default = { }; 96 - }; 97 - # scripts = lib.mkOption { 98 - # type = lib.types.listOf lib.types.package; 99 - # default = [ ]; 100 - # description = "Scripts to add to mpv via override."; 101 - # }; 102 - # "mpv.input" = lib.mkOption { 103 - # type = file; 104 - # default.content = ""; 105 - # }; 106 - # "mpv.conf" = lib.mkOption { 107 - # type = file; 108 - # default.content = '' 109 - # osd-font-size=20 110 - # ''; 111 - # }; 112 - }; 113 - config = settings; 114 - } 115 - ]; 116 - }; 117 - config = eval.config; 118 - options = eval.options; 119 - in 120 - self.libWithPkgs.${pkgs.system}.makeWrapper config.package { 121 - runtimeInputs = config.extraPackages; 122 - flagSeparator = "="; 123 - flags = config.flags; 124 - passthru = { 125 - inherit options config settings; 126 - }; 127 50 }; 128 51 }