nixos: added yazi as global tui file manager

This commit is contained in:
Tigor Hutasuhut 2024-06-26 13:25:55 +07:00
parent 07feb5d83d
commit 258e7dcf88
3 changed files with 71 additions and 0 deletions

View file

@ -76,5 +76,12 @@
zathura.enable = lib.mkEnableOption "zathura"; zathura.enable = lib.mkEnableOption "zathura";
floorp.enable = lib.mkEnableOption "floorp"; floorp.enable = lib.mkEnableOption "floorp";
}; };
programs = {
yazi.enable = lib.mkOption {
type = lib.types.bool;
default = true;
};
};
}; };
} }

View file

@ -20,5 +20,6 @@
./steam.nix ./steam.nix
./sudo.nix ./sudo.nix
./vial.nix ./vial.nix
./yazi.nix
]; ];
} }

63
system/modules/yazi.nix Normal file
View file

@ -0,0 +1,63 @@
{ config, lib, ... }:
let
cfg = config.profile.programs.yazi;
inherit (lib) mkIf;
in
{
config = mkIf cfg.enable {
programs.yazi = {
enable = true;
settings = {
# https://yazi-rs.github.io/docs/configuration/yazi
yazi = {
manager = {
# 1/8 width for parent, 4/8 width for current, 3/8 width for preview
ratio = [ 1 4 3 ];
sort_by = "natural";
sort_sensitive = false;
sort_dir_first = true;
linemode = "permissions";
show_hidden = true;
show_symlink = true;
scrolloff = 5;
};
opener = {
edit = [
{ run = ''nvim "$@"''; block = true; desc = "Edit in Neovim"; }
];
play = [
{ run = ''mpv "$@"''; orphan = true; desc = "Play in MPV"; }
];
open = [
{ run = ''xdg-open "$@"''; desc = "Open"; }
];
};
open = {
rules = [
{
mime = "text/*";
use = "edit";
}
{
mime = "video/*";
use = "play";
}
{
mime = "application/json";
use = "edit";
}
# Multiple openers for a single rule
{
name = "*.html";
use = [ "open" "edit" ];
}
];
append_rules = [
{ name = "*"; use = "open"; }
];
};
};
};
};
};
}