This repository has no description
3.7 kB
128 lines
1{
2 self,
3 lib,
4 ...
5}:
6{
7 perSystem =
8 { pkgs, self', ... }:
9 {
10 legacyPackages.wrappers.mpv = self.wrapLib.mkWrapper (wlib: {
11 inherit pkgs;
12 module =
13 { config, ... }:
14 {
15 options = {
16 scripts = lib.mkOption {
17 type = lib.types.listOf lib.types.package;
18 default = [ ];
19 description = "Scripts to add to mpv via override.";
20 };
21 "mpv.input" = lib.mkOption {
22 type = wlib.types.file;
23 default.content = "";
24 };
25 "mpv.conf" = lib.mkOption {
26 type = wlib.types.file;
27 default.content = ''
28 osd-font-size=20
29 '';
30 };
31 };
32 config.flags = {
33 "--no-config" = { };
34 "--input-conf" = config."mpv.input".path;
35 "--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 };
42 };
43 });
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 };
128}