1{
2 config,
3 lib,
4 pkgs,
5 ...
6}:
7
8let
9 cfg = config.programs.yazi;
10
11 settingsFormat = pkgs.formats.toml { };
12
13 files = [
14 "yazi"
15 "theme"
16 "keymap"
17 ];
18in
19{
20 options.programs.yazi = {
21 enable = lib.mkEnableOption "yazi terminal file manager";
22
23 package = lib.mkPackageOption pkgs "yazi" { };
24
25 settings = lib.mkOption {
26 type =
27 with lib.types;
28 submodule {
29 options = (
30 lib.listToAttrs (
31 map (
32 name:
33 lib.nameValuePair name (
34 lib.mkOption {
35 inherit (settingsFormat) type;
36 default = { };
37 description = ''
38 Configuration included in `${name}.toml`.
39
40 See https://yazi-rs.github.io/docs/configuration/${name}/ for documentation.
41 '';
42 }
43 )
44 ) files
45 )
46 );
47 };
48 default = { };
49 description = ''
50 Configuration included in `$YAZI_CONFIG_HOME`.
51 '';
52 };
53
54 initLua = lib.mkOption {
55 type = with lib.types; nullOr path;
56 default = null;
57 description = ''
58 The init.lua for Yazi itself.
59 '';
60 example = lib.literalExpression "./init.lua";
61 };
62
63 plugins = lib.mkOption {
64 type =
65 with lib.types;
66 attrsOf (oneOf [
67 path
68 package
69 ]);
70 default = { };
71 description = ''
72 Lua plugins.
73
74 See https://yazi-rs.github.io/docs/plugins/overview/ for documentation.
75 '';
76 example = lib.literalExpression ''
77 {
78 foo = ./foo;
79 bar = pkgs.bar;
80 }
81 '';
82 };
83
84 flavors = lib.mkOption {
85 type =
86 with lib.types;
87 attrsOf (oneOf [
88 path
89 package
90 ]);
91 default = { };
92 description = ''
93 Pre-made themes.
94
95 See https://yazi-rs.github.io/docs/flavors/overview/ for documentation.
96 '';
97 example = lib.literalExpression ''
98 {
99 foo = ./foo;
100 bar = pkgs.bar;
101 }
102 '';
103 };
104
105 };
106
107 config = lib.mkIf cfg.enable {
108 environment.systemPackages = [
109 (cfg.package.override {
110 inherit (cfg)
111 settings
112 initLua
113 plugins
114 flavors
115 ;
116 })
117 ];
118 };
119
120 meta = {
121 maintainers = with lib.maintainers; [ linsui ];
122 };
123}