From c11584e31ecdfa8fbb3684103e18dc1809188e44 Mon Sep 17 00:00:00 2001 From: Sweetbread Date: Mon, 1 Sep 2025 18:18:53 +0300 Subject: [PATCH] yazi: set up plugins --- flake.lock | 93 ++++++++++++++++++++++++++++++++++++++++++- flake.nix | 1 + modules/user/yazi.nix | 57 ++++++++++++++++---------- 3 files changed, 130 insertions(+), 21 deletions(-) diff --git a/flake.lock b/flake.lock index 2b5dd04..22dcc97 100644 --- a/flake.lock +++ b/flake.lock @@ -230,6 +230,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": { @@ -738,6 +756,22 @@ "type": "github" } }, + "nixpkgs_8": { + "locked": { + "lastModified": 1756288264, + "narHash": "sha256-Om8adB1lfkU7D33VpR+/haZ2gI5r3Q+ZbIPzE5sYnwE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ddd1826f294a0ee5fdc198ab72c8306a0ea73aa9", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "nur": { "inputs": { "flake-parts": [ @@ -797,7 +831,8 @@ "nixpkgs-fixed": "nixpkgs-fixed", "nixpkgs-stable": "nixpkgs-stable", "sops-nix": "sops-nix", - "stylix": "stylix" + "stylix": "stylix", + "yazi": "yazi" } }, "rust-overlay": { @@ -818,6 +853,27 @@ "type": "github" } }, + "rust-overlay_2": { + "inputs": { + "nixpkgs": [ + "yazi", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1756348497, + "narHash": "sha256-xJp3VnoYh4kpsaKFO/7SsGbwOz7pI1ZmjbqpXEuR2cw=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "0adf92c70d23fb4f703aea5d3ebb51ac65994f7f", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, "sops-nix": { "inputs": { "nixpkgs": "nixpkgs_6" @@ -898,6 +954,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": { @@ -1019,6 +1090,26 @@ "repo": "xdg-desktop-portal-hyprland", "type": "github" } + }, + "yazi": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs_8", + "rust-overlay": "rust-overlay_2" + }, + "locked": { + "lastModified": 1756394761, + "narHash": "sha256-mQShrxSE95ChGn8vuMEOaHV2NdbvvHO105CCskLupJw=", + "owner": "sxyazi", + "repo": "yazi", + "rev": "eb537733a2c5b09649b56284b74dbdd4e70006ec", + "type": "github" + }, + "original": { + "owner": "sxyazi", + "repo": "yazi", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index d9f1db1..e094bb7 100644 --- a/flake.nix +++ b/flake.nix @@ -26,6 +26,7 @@ sops-nix.url = "github:Mic92/sops-nix"; stylix.url = "github:danth/stylix"; ags.url = "github:Aylur/ags/3ed9737bdbc8fc7a7c7ceef2165c9109f336bff6"; + yazi.url = "github:sxyazi/yazi"; hyprland.url = "github:hyprwm/Hyprland"; hyprland-plugins = { diff --git a/modules/user/yazi.nix b/modules/user/yazi.nix index 7030b8a..23e7af2 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 = "e95c7b384e7b0a9793fe1471f0f8f7810ef2a7ed"; - hash = "sha256-TUS+yXxBOt6tL/zz10k4ezot8IgVg0/2BbS8wPs9KcE="; - }; - starship = pkgs.fetchFromGitHub { - owner = "Rolv-Apneseth"; - repo = "starship.yazi"; - rev = "a63550b2f91f0553cc545fd8081a03810bc41bc0"; - sha256 = "sha256-PYeR6fiWDbUMpJbTFSkM57FzmCbsB4W4IXXe25wLncg="; - }; -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"; @@ -29,17 +23,35 @@ in { 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() ''; @@ -48,7 +60,7 @@ in { mgr.prepend_keymap = [ { on = "T"; - run = "plugin --sync max-preview"; + run = "plugin toggle-pane max-preview"; desc = "Maximize or restore the preview pane"; } { @@ -56,6 +68,11 @@ in { run = "plugin chmod"; desc = "Chmod on selected files"; } + { + on = ["M"]; + run = "plugin mount"; + desc = "Open mount menu"; + } { on = [ "" ]; run = ''shell '${lib.getExe pkgs.xdragon} -x -i -T "$@"' --confirm'';