about summary refs log tree commit diff
path: root/nixos/modules/programs/yazi.nix
blob: d9f38d8d81185aeab2e0ffbf46dcaf4ca8590ddf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
{ config, lib, pkgs, ... }:

let
  cfg = config.programs.yazi;

  settingsFormat = pkgs.formats.toml { };

  files = [ "yazi" "theme" "keymap" ];
in
{
  options.programs.yazi = {
    enable = lib.mkEnableOption "yazi terminal file manager";

    package = lib.mkPackageOption pkgs "yazi" { };

    settings = lib.mkOption {
      type = with lib.types; submodule {
        options = (lib.listToAttrs (map
          (name: lib.nameValuePair name (lib.mkOption {
            inherit (settingsFormat) type;
            default = { };
            description = ''
              Configuration included in `${name}.toml`.

              See https://yazi-rs.github.io/docs/configuration/${name}/ for documentation.
            '';
          }))
          files));
      };
      default = { };
      description = ''
        Configuration included in `$YAZI_CONFIG_HOME`.
      '';
    };

    initLua = lib.mkOption {
      type = with lib.types; nullOr path;
      default = null;
      description = ''
        The init.lua for Yazi itself.
      '';
      example = lib.literalExpression "./init.lua";
    };

    plugins = lib.mkOption {
      type = with lib.types; attrsOf (oneOf [ path package ]);
      default = { };
      description = ''
        Lua plugins.

        See https://yazi-rs.github.io/docs/plugins/overview/ for documentation.
      '';
      example = lib.literalExpression ''
        {
          foo = ./foo;
          bar = pkgs.bar;
        }
      '';
    };

    flavors = lib.mkOption {
      type = with lib.types; attrsOf (oneOf [ path package ]);
      default = { };
      description = ''
        Pre-made themes.

        See https://yazi-rs.github.io/docs/flavors/overview/ for documentation.
      '';
      example = lib.literalExpression ''
        {
          foo = ./foo;
          bar = pkgs.bar;
        }
      '';
    };

  };

  config = lib.mkIf cfg.enable {
    environment.systemPackages = [
      (cfg.package.override {
        inherit (cfg) settings initLua plugins flavors;
      })
    ];
  };

  meta = {
    maintainers = with lib.maintainers; [ linsui ];
  };
}