nixos/yazi: init
This commit is contained in:
parent
d816b5ab44
commit
6b2934d6e9
1 changed files with 49 additions and 0 deletions
49
nixos/modules/programs/yazi.nix
Normal file
49
nixos/modules/programs/yazi.nix
Normal file
|
@ -0,0 +1,49 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
cfg = config.programs.yazi;
|
||||
|
||||
settingsFormat = pkgs.formats.toml { };
|
||||
|
||||
names = [ "yazi" "theme" "keymap" ];
|
||||
in
|
||||
{
|
||||
options.programs.yazi = {
|
||||
enable = lib.mkEnableOption (lib.mdDoc "yazi terminal file manager");
|
||||
|
||||
package = lib.mkPackageOptionMD 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 = lib.mdDoc ''
|
||||
Configuration included in `${name}.toml`.
|
||||
|
||||
See https://github.com/sxyazi/yazi/blob/v${cfg.package.version}/config/docs/${name}.md for documentation.
|
||||
'';
|
||||
}))
|
||||
names);
|
||||
};
|
||||
default = { };
|
||||
description = lib.mdDoc ''
|
||||
Configuration included in `$YAZI_CONFIG_HOME`.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
environment = {
|
||||
systemPackages = [ cfg.package ];
|
||||
variables.YAZI_CONFIG_HOME = "/etc/yazi/";
|
||||
etc = lib.attrsets.mergeAttrsList (map
|
||||
(name: lib.optionalAttrs (cfg.settings.${name} != { }) {
|
||||
"yazi/${name}.toml".source = settingsFormat.generate "${name}.toml" cfg.settings.${name};
|
||||
})
|
||||
names);
|
||||
};
|
||||
};
|
||||
meta.maintainers = with lib.maintainers; [ linsui ];
|
||||
}
|
Loading…
Reference in a new issue