From be16e9a8e88c0ac9699b0abfec7fae8cc565ede3 Mon Sep 17 00:00:00 2001 From: Kirill Date: Wed, 24 Dec 2025 21:05:07 +0300 Subject: [PATCH] feat(yazi): New yazi conf --- flake.lock | 93 ++++++++++++++++++++++++++++++++++++++++++- flake.nix | 3 ++ modules/user/yazi.nix | 83 ++++++++++++++++++++++++++++---------- 3 files changed, 157 insertions(+), 22 deletions(-) diff --git a/flake.lock b/flake.lock index 576ccc8..dde2613 100644 --- a/flake.lock +++ b/flake.lock @@ -233,6 +233,24 @@ "type": "github" } }, + "flake-utils": { + "inputs": { + "systems": "systems_3" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "fromYaml": { "flake": false, "locked": { @@ -794,6 +812,22 @@ "type": "github" } }, + "nixpkgs_7": { + "locked": { + "lastModified": 1763806073, + "narHash": "sha256-FHsEKDvfWpzdADWj99z7vBk4D716Ujdyveo5+A048aI=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "878e468e02bfabeda08c79250f7ad583037f2227", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "nur": { "inputs": { "flake-parts": [ @@ -853,7 +887,29 @@ "nixpkgs-fixed": "nixpkgs-fixed", "nixpkgs-stable": "nixpkgs-stable", "sops-nix": "sops-nix", - "stylix": "stylix" + "stylix": "stylix", + "yazi": "yazi" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "yazi", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1763952169, + "narHash": "sha256-+PeDBD8P+NKauH+w7eO/QWCIp8Cx4mCfWnh9sJmy9CM=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "ab726555a9a72e6dc80649809147823a813fa95b", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" } }, "sops-nix": { @@ -936,6 +992,21 @@ "type": "github" } }, + "systems_3": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "tinted-foot": { "flake": false, "locked": { @@ -1057,6 +1128,26 @@ "repo": "xdg-desktop-portal-hyprland", "type": "github" } + }, + "yazi": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs_7", + "rust-overlay": "rust-overlay" + }, + "locked": { + "lastModified": 1766141198, + "narHash": "sha256-8oZTaxMknO2C/ojPp+ZI5XZi/J7TEeczYp7I4F5x/E8=", + "owner": "sxyazi", + "repo": "yazi", + "rev": "329c5d28f097dc78c10b436e3df2ab5086d382e7", + "type": "github" + }, + "original": { + "owner": "sxyazi", + "repo": "yazi", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 44d4480..cfd9883 100644 --- a/flake.nix +++ b/flake.nix @@ -8,6 +8,7 @@ "https://hyprland.cachix.org" "https://ezkea.cachix.org" "https://risdeveau.cachix.org" + "https://yazi.cachix.org" ]; extra-trusted-public-keys = [ "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" @@ -15,6 +16,7 @@ "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc=" "ezkea.cachix.org-1:ioBmUbJTZIKsHmWWXPe1FSFbeVe+afhfgqgTSNd34eI=" "risdeveau.cachix.org-1:TsoFSVeLl7iKtUYGX7qsvKPjf2vbNLfLC5v3SAdU8r0=" + "yazi.cachix.org-1:Dcdz63NZKfvUCbDGngQDAZq6kOroIrFoyO064uvLh8k=" ]; }; @@ -28,6 +30,7 @@ nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-25.11"; sops-nix.url = "github:Mic92/sops-nix"; stylix.url = "github:danth/stylix"; + yazi.url = "github:sxyazi/yazi"; hyprland.url = "github:hyprwm/Hyprland/v0.52.1-b"; hyprland-plugins = { diff --git a/modules/user/yazi.nix b/modules/user/yazi.nix index 5db7486..8c4eb8a 100644 --- a/modules/user/yazi.nix +++ b/modules/user/yazi.nix @@ -1,18 +1,12 @@ - { pkgs, lib, ... }: let - yazi-plugins = pkgs.fetchFromGitHub { - owner = "yazi-rs"; - repo = "plugins"; - rev = "864a0210d9ba1e8eb925160c2e2a25342031d8d3"; - hash = "sha256-m3709h7/AHJAtoJ3ebDA40c77D+5dCycpecprjVqj/k="; - }; - starship = pkgs.fetchFromGitHub { - owner = "Rolv-Apneseth"; - repo = "starship.yazi"; - rev = "6fde3b2d9dc9a12c14588eb85cf4964e619842e6"; - sha256 = "sha256-+CSdghcIl50z0MXmFwbJ0koIkWIksm3XxYvTAwoRlDY="; - }; -in { +{ pkgs, lib, inputs, ... }: { + home.packages = with pkgs; [ + ( ouch.override { enableUnfree = true; } ) + ]; + programs.yazi = { + package = inputs.yazi.packages + .${pkgs.stdenv.hostPlatform.system}.default + .override { _7zz = pkgs._7zz-rar; }; enable = true; enableZshIntegration = true; shellWrapperName = "y"; @@ -25,35 +19,82 @@ in { max_width = 1000; max_height = 1000; }; + plugin = { + preloaders = [ + { name = "*.crdownload"; run = "noop"; } + ]; + + prepend_previewers = [ + { mime = "application/xz"; run = "ouch"; } + { mime = "application/zip"; run = "ouch"; } + { mime = "application/rar"; run = "ouch"; } + { mime = "application/gzip"; run = "ouch"; } + { mime = "application/7z-compressed"; run = "ouch"; } + ]; + + prepend_fetchers = [ + { id = "git"; mime = "*"; run = "git"; } + ]; + }; }; - plugins = { - chmod = "${yazi-plugins}/chmod.yazi"; - full-border = "${yazi-plugins}/full-border.yazi"; - # max-preview = "${yazi-plugins}/max-preview.yazi"; - starship = starship; + plugins = with pkgs.yaziPlugins; { + inherit + chmod + ouch + full-border + starship + mount + git + toggle-pane + ; }; initLua = '' + require("git"):setup() require("full-border"):setup() require("starship"):setup() + + Status:children_add(function() + local h = cx.active.current.hovered + if not h or ya.target_family() ~= "unix" then + return "" + end + + return ui.Line { + ui.Span(ya.user_name(h.cha.uid) or tostring(h.cha.uid)):fg("magenta"), + ":", + ui.Span(ya.group_name(h.cha.gid) or tostring(h.cha.gid)):fg("magenta"), + " ", + } + end, 500, Status.RIGHT) ''; keymap = { mgr.prepend_keymap = [ { on = "T"; - run = "plugin --sync max-preview"; + run = "plugin toggle-pane max-preview"; desc = "Maximize or restore the preview pane"; } + { + on = "Y"; + run = ''shell -- for path in "$@"; do echo "file://$path"; done | wl-copy -t text/uri-list''; + desc = "Copy files into system clipboard"; + } { on = ["c" "m"]; run = "plugin chmod"; desc = "Chmod on selected files"; } + { + on = ["M"]; + run = "plugin mount"; + desc = "Open mount menu"; + } { on = [ "" ]; - run = ''shell '${lib.getExe pkgs.dragon-drop} -x -i -T "$@"' --confirm''; + run = "shell '${lib.getExe pkgs.dragon-drop} -x -i -T %h'"; } { on = [ "g" "" ];