|
| 1 | +{ |
| 2 | + config, |
| 3 | + lib, |
| 4 | + pkgs, |
| 5 | + ... |
| 6 | +}: let |
| 7 | + inherit (lib.modules) mkIf; |
| 8 | + inherit (lib.options) mkOption mkEnableOption mkPackageOption; |
| 9 | + |
| 10 | + toml = pkgs.formats.toml {}; |
| 11 | + |
| 12 | + cfg = config.rum.programs.yazi; |
| 13 | +in { |
| 14 | + options.rum.programs.yazi = { |
| 15 | + enable = mkEnableOption "yazi file manager"; |
| 16 | + |
| 17 | + package = mkPackageOption pkgs "yazi" {nullable = true;}; |
| 18 | + |
| 19 | + settings = mkOption { |
| 20 | + inherit (toml) type; |
| 21 | + default = {}; |
| 22 | + example = { |
| 23 | + mgr = { |
| 24 | + show_hidden = true; |
| 25 | + }; |
| 26 | + }; |
| 27 | + description = '' |
| 28 | + The configurations converted to TOML and written to {file}`$XDG_CONFIG_HOME/yazi/yazi.toml`. |
| 29 | + Please reference [yazi's configuration documentation] for configuration options. |
| 30 | +
|
| 31 | + [yazi's configuration documentation]: https://yazi-rs.github.io/docs/configuration/yazi |
| 32 | + ''; |
| 33 | + }; |
| 34 | + |
| 35 | + keymap = mkOption { |
| 36 | + inherit (toml) type; |
| 37 | + default = {}; |
| 38 | + example = { |
| 39 | + mgr.prepend_keymap = [ |
| 40 | + { |
| 41 | + on = "<C-a>"; |
| 42 | + run = "my-cmd1"; |
| 43 | + desc = "Single command with `Ctrl + a`"; |
| 44 | + } |
| 45 | + ]; |
| 46 | + }; |
| 47 | + description = '' |
| 48 | + The keymap configurations converted to TOML and written to {file}`$XDG_CONFIG_HOME/yazi/keymap.toml`. |
| 49 | + Please reference [yazi's keymap configuration documentation] for configuration options. |
| 50 | +
|
| 51 | + [yazi's keymap configuration documentation]: https://yazi-rs.github.io/docs/configuration/keymap |
| 52 | + ''; |
| 53 | + }; |
| 54 | + |
| 55 | + theme = mkOption { |
| 56 | + inherit (toml) type; |
| 57 | + default = {}; |
| 58 | + example = { |
| 59 | + flavor = { |
| 60 | + dark = "dracula"; |
| 61 | + light = "gruvbox"; |
| 62 | + }; |
| 63 | + }; |
| 64 | + description = '' |
| 65 | + The keymap configurations converted to TOML and written to {file}`$XDG_CONFIG_HOME/yazi/theme.toml`. |
| 66 | + Please reference [yazi's theming configuration documentation] for configuration options. |
| 67 | +
|
| 68 | + [yazi's theming configuration documentation]: https://yazi-rs.github.io/docs/configuration/theme |
| 69 | + ''; |
| 70 | + }; |
| 71 | + }; |
| 72 | + |
| 73 | + config = mkIf cfg.enable { |
| 74 | + packages = mkIf (cfg.package != null) [cfg.package]; |
| 75 | + |
| 76 | + xdg.config.files = { |
| 77 | + "yazi/yazi.toml".source = mkIf (cfg.settings != {}) ( |
| 78 | + toml.generate "yazi-config.toml" cfg.settings |
| 79 | + ); |
| 80 | + "yazi/keymap.toml".source = mkIf (cfg.keymap != {}) ( |
| 81 | + toml.generate "yazi-keymap-config.toml" cfg.keymap |
| 82 | + ); |
| 83 | + "yazi/theme.toml".source = mkIf (cfg.theme != {}) ( |
| 84 | + toml.generate "yazi-theme-config.toml" cfg.theme |
| 85 | + ); |
| 86 | + }; |
| 87 | + }; |
| 88 | +} |
0 commit comments