Jump to content

Yazi: Difference between revisions

From Official NixOS Wiki
Layer-09 (talk | contribs)
m Removed numbering
m update link to yazi flake documentation
 
(18 intermediate revisions by 12 users not shown)
Line 1: Line 1:
[https://yazi-rs.github.io/ Yazi] is a blazing-fast terminal file manager developed in Rust, leveraging non-blocking async I/O to offer an efficient, user-friendly, and highly customizable file management experience. It stands out for its full asynchronous support, where all I/O operations are asynchronous, and CPU tasks are distributed across multiple threads, maximizing resource utilization. This design choice significantly enhances performance and responsiveness.
<strong>[https://yazi-rs.github.io Yazi]</strong> is a blazing-fast terminal file manager developed in Rust, using non-blocking async I/O for an efficient, user-friendly, and highly customizable file management experience. It features full asynchronous support, distributing CPU tasks across multiple threads to maximize resource use and improve performance.


Yazi introduces powerful async task scheduling and management capabilities, providing real-time progress updates, task cancellation, and internal task prioritization. It supports multiple image protocols natively and integrates with Überzug++ for extensive terminal compatibility. Additionally, Yazi includes built-in code highlighting and image decoding functionalities, combined with a pre-loading mechanism that speeds up both image and regular file loading processes.
It offers powerful async task scheduling with real-time progress updates, task cancellation, and internal prioritization. It supports multiple image protocols natively and integrates with [https://github.com/jstkdng/ueberzugpp Überzug++] for broad terminal compatibility. Additionally, Yazi includes built-in code highlighting and image decoding functionalities, along with a pre-loading mechanism to speed up file loading processes.


== Installation ==
== Installation ==


==== Using nix-shell ====
There are several ways to install Yazi on NixOS.
<syntaxhighlight lang="bash" start="3">
 
=== Temporary Shell ===
To temporarily use Yazi in your current shell session, run:
<syntaxhighlight lang="bash">
nix-shell -p yazi
nix-shell -p yazi
</syntaxhighlight>
</syntaxhighlight>


==== System-Wide Installation on NixOS ====
=== System-wide ===
<syntaxhighlight lang="text">
To install Yazi for all users on the system, add it to your {{ic|configuration.nix}}:
environment.systemPackages = [
<syntaxhighlight lang="nix">
  pkgs.yazi
programs.yazi.enable = true;
];
</syntaxhighlight>
</syntaxhighlight>After modifying your configuration, apply the changes by running:<syntaxhighlight lang="bash">
 
After adding the option, rebuild your system:
<syntaxhighlight lang="bash">
sudo nixos-rebuild switch
sudo nixos-rebuild switch
</syntaxhighlight>
</syntaxhighlight>


==== User-Specific Installation with Home Manager ====
=== Home Manager ===
<syntaxhighlight lang="text">
To install Yazi for a single user, add it to your Home Manager configuration:
home.packages = [
<syntaxhighlight lang="nix">
  pkgs.yazi
programs.yazi.enable = true;
];
</syntaxhighlight>
</syntaxhighlight>After updating your configuration, apply the changes by running:<syntaxhighlight lang="bash">
 
After adding the option, apply the changes:
<syntaxhighlight lang="bash">
home-manager switch
home-manager switch
</syntaxhighlight>
</syntaxhighlight>


== Configuration ==
== Configuration ==
As mentioned above, there are both [https://search.nixos.org/options?channel=unstable&from=0&size=50&sort=relevance&type=packages&query=programs.yazi NixOS options] and [https://nix-community.github.io/home-manager/options.xhtml#opt-programs.yazi.enable home-manager options] for configuring Yazi.


==== Basic ====
==== Advanced ====
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
programs.yazi = {
    enable = true;
};
</syntaxhighlight>
==== Advanced ====
The configuration below is using home manager, but the same can be achieved if system-wide.<syntaxhighlight lang="nix">
programs.yazi = {
programs.yazi = {
   enable = true;
   enable = true;
   settings = {
   settings = {
     manager = {
     yazi = {
      ratio = [
        1
        4
        3
      ];
       sort_by = "natural";
       sort_by = "natural";
      sort_sensitive = true;
      sort_reverse = false;
      sort_dir_first = true;
      linemode = "none";
       show_hidden = true;
       show_hidden = true;
       show_symlink = true;
       show_symlink = true;
Line 50: Line 60:
     preview = {
     preview = {
       image_filter = "lanczos3";
       image_filter = "lanczos3";
       image_quality = 80;
       image_quality = 90;
      tab_size = 1;
       max_width = 600;
       max_width = 600;
       max_height = 900;
       max_height = 900;
      cache_dir = "";
       ueberzug_scale = 1;
       ueberzug_scale = 1;
       ueberzug_offset = [0 0 0 0];
       ueberzug_offset = [
        0
        0
        0
        0
      ];
     };
     };


Line 62: Line 79:
       bizarre_retry = 5;
       bizarre_retry = 5;
     };
     };
  };
}


  open = {
</syntaxhighlight>
      rules = [
        {
          use = "open";
          mime = "image/*";
        }
        {
          use = ["play" "reveal"];
          mime = "video/*";
        }
        {
          use = ["play" "reveal"];
          mime = "audio/*";
        }
      ];
    };


    opener = {
== Using separate files ==
      edit = [
If you would like to use your existing files to keep them portable, you can import them into your configuration directly to be read and built by nix.
        {
{{File|3=programs.yazi = {
          exec = "nvim \"$@\"";
  enable = true;
          block = true;
  plugins = {
          for = "unix";
    inherit (pkgs.yaziPlugins) mount;
        }
      ];
      open = [
        {
          exec = "qimgv \"$@\"";
          desc = "Open";
        }
      ];
      reveal = [
        {
          exec = "''${pkgs.exiftool}/bin/exiftool \"$1\"; echo \"Press enter to exit\"; read _''";
          block = true;
          desc = "Show EXIF";
        }
      ];
      play = [
        {
          exec = "mpv \"$@\"";
          orphan = true;
        }
        {
          exec = "''${pkgs.mediainfo}/bin/mediainfo \"$1\"; echo \"Press enter to exit\"; read _''";
          block = true;
          desc = "Show media info";
        }
      ];
      archive = [
        {
          exec = "unar \"$1\"";
          desc = "Extract here";
        }
      ];
    };
   };
   };
  #initLua = ./init.lua
  settings = lib.importTOML ./yazi.toml; # yazi/yazi.toml
  keymap = lib.importTOML ./keymap.toml;
  theme = lib.importTOML ./theme.toml;     
};|name=/etc/nixos/configuration.nix|lang=nix}}


  keymap = {
== Plugins ==
    manager.keymap = [
 
      {
==== Installing Plugins ====
        exec = "shell 'dragon -x -i -T \"$1\"' --confirm";
Many yazi plugins are [https://search.nixos.org/packages?channel=unstable&from=0&size=50&buckets=%7B%22package_attr_set%22%3A%5B%22yaziPlugins%22%5D%2C%22package_license_set%22%3A%5B%5D%2C%22package_maintainers_set%22%3A%5B%5D%2C%22package_platforms%22%3A%5B%5D%7D&sort=relevance&type=packages&query=yaziPlugins packaged in nixpkgs].
        on = ["<C-d>"];
 
      }
There are some additional yazi plugins packaged in the [https://github.com/lordkekz/nix-yazi-plugins nix-yazi-plugins] flake. It also provides home-manager modules for configuring the plugins' options.
      {
 
        exec = "arrow -1";
==== home-manager ====
        desc = "Move cursor up";
{{File|3=programs.yazi = {
        on = ["<Up>"];
  enable = true;
      }
  plugins = with pkgs.yaziPlugins; {
    ];
    # Plugins that don't call setup() can be configured in one line
    completion.keymap = [
    smart-enter.package = smart-enter;
      {
    chmod.package = chmod;
        on = ["<Esc>"];
 
        run = "close";
     # Yatline-Catppuccin needs to be setup into a variable later
        desc = "Cancel completion";
    yatline-catppuccin.package = yatline-catppuccin;  
      }
      {
        on = ["<Tab>"];
        run = "close --submit";
        desc = "Submit the completion";
      }
     ];


     tasks.keymap = [
     # Plugins with setup({settings})
      {
     yatline = {
        exec = "close";
       package = yatline;
        on = ["<Esc>"];
       setup = true;
      }
       settings = {
      {
         tab_width = 20;
        exec = "arrow -1";
         # Return as lua code
        on = ["<Up>"];
         theme = lib.mkLuaInline ''require("yatline-catppuccin"):setup("mocha")'';
      }
       };
     ];
     };
    select.keymap = [
       {
        exec = "close";
        on = ["<Esc>"];
       }
      {
        exec = "close --submit";
        on = ["<Enter>"];
       }
    ];
    input.keymap = [
      {
         exec = "close";
         on = ["<Esc>"];
      }
      {
         exec = "close --submit";
        on = ["<Enter>"];
       }
    ];
     help.keymap = [
      {
        exec = "escape";
        on = ["<Esc>"];
      }
      {
        exec = "filter";
        on = ["/"];
      }
    ];
   };
   };
  theme = {
};|name=/etc/nixos/configuration.nix|lang=nix}}
    manager = {
 
      border_symbol = " ";
== Flavors ==
    };
With <code>plugins = {}</code> you can install plugins into your Yazi configuration directory  (<code>~/.config/yazi</code> on unix-like systems by default). Similarly, when installing flavors or themes, use <code>flavors = {}</code>. For example:<syntaxhighlight lang="nix">
    icon = {
flavors = {
      rules = [
  inherit (pkgs.yaziPlugins) kanagawa;
        {
};
          name = "*.jsx";
theme = {
          text = "";
  flavor = {
          fg = "#20c2e3";
    dark = "kanagawa";
        }
        {
          name = "*.lua";
          text = "";
          fg = "#51a0cf";
        }
        {
          name = "*.nix";
          text = "";
          fg = "#7ebae4";
        }
      ];
    };
    filetype = {
      rules = [
        # Images
        {
          mime = "image/*";
          fg = "#7ebae4";
        }
      ];
    };
   };
   };
};
};
</syntaxhighlight>
</syntaxhighlight>


== Tips and Tricks ==
== Tips and tricks ==


==== Where to see a list of options? ====
==== Bleeding edge ====
The home manager options are defined in the following [https://nix-community.github.io/home-manager/options.xhtml#opt-programs.yazi.enable Home Manager Options Manual].
The upstream repository provides a flake so that Nix users can easily keep up with the bleeding edge.<ref>https://yazi-rs.github.io/docs/installation/#flakes</ref><syntaxhighlight lang="nix">
inputs = {
    yazi.url = "github:sxyazi/yazi";
};
</syntaxhighlight>Afterwards, you can use the new package.<syntaxhighlight lang="nix">
# Global
environment.systemPackages = [ yazi.packages.${pkgs.stdenv.hostPlatform.system}.default ];
# or, if you use the module
programs.yazi.package = yazi.packages.${pkgs.stdenv.hostPlatform.system}.default;


The system-wide options are listed on [https://mynixos.com/search?q=yazi MyNixOS].
# Home Manager
home.packages = [ yazi.packages.${pkgs.stdenv.hostPlatform.system}.default ];
# or, if you use the module
programs.yazi.package = yazi.packages.${pkgs.stdenv.hostPlatform.system}.default;
</syntaxhighlight>Pre-built artifacts are served at https://yazi.cachix.org, so that Nix users don't have to build Yazi on their machine.<ref>https://yazi-rs.github.io/docs/installation/#cache</ref><syntaxhighlight lang="nix">
nix = {
  settings = {
    substitute = true;
    substituters = [
      "https://yazi.cachix.org"
    ];
    trusted-public-keys = [
      "yazi.cachix.org-1:Dcdz63NZKfvUCbDGngQDAZq6kOroIrFoyO064uvLh8k="
    ];
  };
};
</syntaxhighlight>


==== Can this be used with stylix? ====
==== Stylix integration ====
Yes, it can. See the following configuration:<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
theme = with config.stylix.base16Scheme; {
theme = with config.stylix.base16Scheme; {
   filetype = {
   filetype = {
Line 254: Line 195:
   };
   };
};
};
</syntaxhighlight>Stylix can also do it automatically for you. You have to set:<syntaxhighlight lang="nix">
</syntaxhighlight>Stylix can do it automatically for you if the following option is set:<syntaxhighlight lang="nix">
stylix.targets.yazi.enable = true;
stylix.targets.yazi.enable = true;
</syntaxhighlight>
</syntaxhighlight>


==== How to map yazi to a key? ====
==== Key mapping ====
It depends on the window manager that you are using. On [https://wiki.nixos.org/wiki/Hyprland Hyprland] it's fairly easy:<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
# Hyprland
bind = [
bind = [
   "$mod, E, exec, kitty -e yazi"
   "$mod, E, exec, kitty -e yazi"
];
];
</syntaxhighlight>
</syntaxhighlight>
==== Easy directory keymap ====
{{File|3=programs.yazi = {
  enable = true;
  keymap.mgr.prepend_keymap = [
      # Add your other keymaps here
    ] ++ lib.mapAttrsToList(dir: key: let
      keys = if lib.isString key then [ "b" key ] else [ "b" ] ++ key;
    in {
      on = keys;
      run = ''cd ${dir}'';
      desc = ''Go to ${dir}'';
    }) {
      "/mnt/drive/" = "d";
      "~/.steam/steam/steamapps/" = ["s" "s"];
      "~/.steam/steam/steamapps/common" = ["s" "c"];
    };
};|name=/etc/nixos/configuration.nix|lang=nix}}


== Troubleshooting ==
== Troubleshooting ==
===RAR file extraction===
By default, yazi depends on _7zz in nixpkgs for extraction and previewing purposes. This does not support RAR files by default. To enable support, you can override the _7zz in the dependencies into unfree rar version.
<syntaxHighlight lang=text>
pkgs.yazi.override {_7zz = pkgs._7zz-rar; }
</syntaxHighlight>
== See also ==
*[https://search.nixos.org/options?channel=unstable&query=programs.yazi NixOS options for Yazi]
*[https://yazi-rs.github.io/docs/installation/ Yazi official documentation]


== References ==
== References ==
# https://github.com/sxyazi/yazi
# https://yazi-rs.github.io/
# https://mynixos.com/search?q=yazi
# https://nix-community.github.io/home-manager/options.xhtml#opt-programs.yazi.enable
# https://stylix.danth.me/options/hm.html#stylixtargetsyazienable
[[Category:Applications]]
[[Category:Applications]]
[[Category:File Manager]]
[[Category:File Manager]]

Latest revision as of 18:52, 19 July 2026

Yazi is a blazing-fast terminal file manager developed in Rust, using non-blocking async I/O for an efficient, user-friendly, and highly customizable file management experience. It features full asynchronous support, distributing CPU tasks across multiple threads to maximize resource use and improve performance.

It offers powerful async task scheduling with real-time progress updates, task cancellation, and internal prioritization. It supports multiple image protocols natively and integrates with Überzug++ for broad terminal compatibility. Additionally, Yazi includes built-in code highlighting and image decoding functionalities, along with a pre-loading mechanism to speed up file loading processes.

Installation

There are several ways to install Yazi on NixOS.

Temporary Shell

To temporarily use Yazi in your current shell session, run:

nix-shell -p yazi

System-wide

To install Yazi for all users on the system, add it to your configuration.nix:

programs.yazi.enable = true;

After adding the option, rebuild your system:

sudo nixos-rebuild switch

Home Manager

To install Yazi for a single user, add it to your Home Manager configuration:

programs.yazi.enable = true;

After adding the option, apply the changes:

home-manager switch

Configuration

As mentioned above, there are both NixOS options and home-manager options for configuring Yazi.

Advanced

programs.yazi = {
  enable = true;
  settings = {
    yazi = {
      ratio = [
        1
        4
        3
      ];
      sort_by = "natural";
      sort_sensitive = true;
      sort_reverse = false;
      sort_dir_first = true;
      linemode = "none";
      show_hidden = true;
      show_symlink = true;
    };

    preview = {
      image_filter = "lanczos3";
      image_quality = 90;
      tab_size = 1;
      max_width = 600;
      max_height = 900;
      cache_dir = "";
      ueberzug_scale = 1;
      ueberzug_offset = [
        0
        0
        0
        0
      ];
    };

    tasks = {
      micro_workers = 5;
      macro_workers = 10;
      bizarre_retry = 5;
    };
  };
}

Using separate files

If you would like to use your existing files to keep them portable, you can import them into your configuration directly to be read and built by nix.

❄︎ /etc/nixos/configuration.nix
programs.yazi = {
  enable = true;
  plugins = {
    inherit (pkgs.yaziPlugins) mount;
  };
  #initLua = ./init.lua
  settings = lib.importTOML ./yazi.toml; # yazi/yazi.toml
  keymap = lib.importTOML ./keymap.toml;
  theme = lib.importTOML ./theme.toml;      
};

Plugins

Installing Plugins

Many yazi plugins are packaged in nixpkgs.

There are some additional yazi plugins packaged in the nix-yazi-plugins flake. It also provides home-manager modules for configuring the plugins' options.

home-manager

❄︎ /etc/nixos/configuration.nix
programs.yazi = {
  enable = true;
  plugins = with pkgs.yaziPlugins; {
    # Plugins that don't call setup() can be configured in one line
    smart-enter.package = smart-enter;
    chmod.package = chmod;

    # Yatline-Catppuccin needs to be setup into a variable later
    yatline-catppuccin.package = yatline-catppuccin;    

    # Plugins with setup({settings})
    yatline = {
      package = yatline;
      setup = true;
      settings = {
        tab_width = 20;
        # Return as lua code
        theme = lib.mkLuaInline ''require("yatline-catppuccin"):setup("mocha")'';
      };
    };
  };
};

Flavors

With plugins = {} you can install plugins into your Yazi configuration directory (~/.config/yazi on unix-like systems by default). Similarly, when installing flavors or themes, use flavors = {}. For example:

flavors = {
  inherit (pkgs.yaziPlugins) kanagawa;
};
theme = {
  flavor = {
    dark = "kanagawa";
  };
};

Tips and tricks

Bleeding edge

The upstream repository provides a flake so that Nix users can easily keep up with the bleeding edge.[1]

inputs = {
    yazi.url = "github:sxyazi/yazi";
};

Afterwards, you can use the new package.

# Global
environment.systemPackages = [ yazi.packages.${pkgs.stdenv.hostPlatform.system}.default ];
# or, if you use the module
programs.yazi.package = yazi.packages.${pkgs.stdenv.hostPlatform.system}.default;

# Home Manager
home.packages = [ yazi.packages.${pkgs.stdenv.hostPlatform.system}.default ];
# or, if you use the module
programs.yazi.package = yazi.packages.${pkgs.stdenv.hostPlatform.system}.default;

Pre-built artifacts are served at https://yazi.cachix.org, so that Nix users don't have to build Yazi on their machine.[2]

nix = {
  settings = {
    substitute = true;
    substituters = [
      "https://yazi.cachix.org"
    ];
    trusted-public-keys = [
      "yazi.cachix.org-1:Dcdz63NZKfvUCbDGngQDAZq6kOroIrFoyO064uvLh8k="
    ];
  };
};

Stylix integration

theme = with config.stylix.base16Scheme; {
  filetype = {
    rules = [
      # Images
      {
        mime = "image/*";
        fg = "#${base0B}";
      }

      # Videos
      {
        mime = "video/*";
        fg = "#${base03}";
      }
      # Audio
      {
        mime = "audio/*";
        fg = "#${base08}";
      }
    ];
  };
};

Stylix can do it automatically for you if the following option is set:

stylix.targets.yazi.enable = true;

Key mapping

# Hyprland
bind = [
  "$mod, E, exec, kitty -e yazi"
];

Easy directory keymap

❄︎ /etc/nixos/configuration.nix
programs.yazi = {
  enable = true;
  keymap.mgr.prepend_keymap = [
      # Add your other keymaps here
    ] ++ lib.mapAttrsToList(dir: key: let 
      keys = if lib.isString key then [ "b" key ] else [ "b" ] ++ key;
    in {
      on = keys;
      run = ''cd ${dir}'';
      desc = ''Go to ${dir}'';
    }) {
      "/mnt/drive/" = "d";
      "~/.steam/steam/steamapps/" = ["s" "s"];
      "~/.steam/steam/steamapps/common" = ["s" "c"];
    };
};

Troubleshooting

RAR file extraction

By default, yazi depends on _7zz in nixpkgs for extraction and previewing purposes. This does not support RAR files by default. To enable support, you can override the _7zz in the dependencies into unfree rar version.

pkgs.yazi.override {_7zz = pkgs._7zz-rar; }

See also

References