Help configuring yazi bookmarks plugin

I’m trying to install the bookmarks plugin, to no avail. I’m using this module:

{ pkgs, ... }:
{
  environment.systemPackages = with pkgs; [
    yazi
  ];
  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;
      };

    };
    plugins = {
      inherit (pkgs.yaziPlugins) mount;
      bookmarks = pkgs.yaziPlugins.bookmarks;
    };
  };
}

I don’t seem able to invoke any functionality, and

ya pkg list        
Plugins:
Flavors:

Do I need to configure some settings as well?

Thanks in advance

The module wraps yazi with your config and adds the wrapped yazi to environment.systemPackages, so remove the unconfigured version from your environment.systemPackages.

I didn’t originally have it in environment.systemPackages, but without it I get

Failed to parse config "/nix/store/ma18cxp5y93xh33dqyf9lspn2d3xjg6h-YAZI_CONFIG_HOME/yazi.toml"

Caused by:
TOML parse error at line 3, column 1
  |
3 | show_hidden = true
  | ^^^^^^^^^^^
must be 1-20 characters in kebab-case

Press any key to continue with preset settings...

When I launch yazi.

Just realized I didn’t put this in the Help category. Sorry.

Ah, so you shadowed it with an unconfigured yazi due to the configuration error.

It looks like you’re missing the mgr key. Since it looks like all your settings are for mgr, you can probably just use yazi.mgr instead of yazi under settings.

No worries, just recategorized it myself with my TL3 pemissions.

That sorted it, thank you! However, the plugin still does not seem to load.

ya pkg list only shows packages managed by ya pkg, not ones from the nix wrapper.
It should work if you configure its keybinds:

So the plugin is loaded, and I have added the keymaps to access the functionality. I can add and delete bookmarks, and ' brings up the list of saved bookmarks. However, when I choose one from the list, nothing happens, and there is a background error

runtime error: ?:?: attempt to call a nil value (field 'mgr_emit')
stack traceback:
	?: in function 'bookmarks.entry'

This is my current yaxi.nix

❯ \cat nixos/yazi.nix
{ pkgs, ... }:
{
  # environment.systemPackages = with pkgs; [
  #   yazi
  # ];
  programs.yazi = {
    enable = true;
    settings = {
      yazi.mgr = {
        ratio = [
          1
          3
          3
        ];
        sort_by = "natural";
        sort_sensitive = true;
        sort_reverse = false;
        sort_dir_first = true;
        linemode = "none";
        show_hidden = true;
        show_symlink = true;
      };

      keymap = {
        mgr.prepend_keymap = [
          {
            on = [ "n" ];
            run = "plugin bookmarks save";
            desc = "Save current position as a bookmark";
          }
          {
            on = [ "'" ];
            run = "plugin bookmarks jump";
            desc = "Jump to a bookmark";
          }
          {
            on = [
              "b"
              "d"
            ];
            run = "plugin bookmarks delete";
            desc = "Delete a bookmark";
          }
          {
            on = [
              "b"
              "D"
            ];
            run = "plugin bookmarks delete_all";
            desc = "Delete all bookmarks";
          }
        ];
      };
    };
    plugins = {
      bookmarks = pkgs.yaziPlugins.bookmarks;
    };
  };
}

Getting there.

Oh right, the dedukun/bookmarks.yazi plugin is unmaintained and uses a removed API.
Either apply Update emit call by aresler · Pull Request #61 · dedukun/bookmarks.yazi · GitHub as a patch or use the maintained fork at GitHub - sidhantunnithan/bookmarks.yazi · GitHub.
Use overrideAttrs to either replace src with a pkgs.fetchFromGitHub of the maintained fork, or do (old.patches or [ ]) ++ [ (pkgs.fetchpatch { /* pr patch hash+url */ }) ].

Probably we should just change the nixpkgs source to the maintained fork, though.

I added

  programs.yazi = {
    ...
    package = pkgs.yazi.overrideAttrs (oldAttrs: {
      src = pkgs.fetchFromGitHub {
        owner = "sidhantunnithan";
        repo = "bookmarks.yazi";
        rev = "a61e524a2b74f8f09e5af2265df0a32605f7528c";
        sha256 = "u5AtP6Mp6OwLQps10PNV1xjwjwfDmZxND0NDnIuqZRY=";
      };
    });
    ...
};

but I’m still getting the very same error. I sure appreciate your hanging in with me on this.

That looks like you’re overriding the yazi package src itself (which works because pkgs.yazi is a runCommand-based wrapper, and not the actual yazi rust crate). You should be overridingpkgs.yaziPlugins.bookmarks.

I also just made a nixpkgs PR here, so you won’t need to override once a committer merges it and makes its way into channels:

You’re awesome, thanks. I don’t know what I was thinking on this one lol.

For the record, this is the module that worked. Thanks to your PR, it shouldn’t be necessary in the future, but here it is.

❯ \cat nixos/yazi.nix
{ pkgs, ... }:
{
  programs.yazi = {
    enable = true;
    settings = {
      yazi.mgr = {
        ratio = [
          1
          3
          3
        ];
        sort_by = "natural";
        sort_sensitive = true;
        sort_reverse = false;
        sort_dir_first = true;
        linemode = "none";
        show_hidden = true;
        show_symlink = true;
      };
      keymap = {
        mgr.prepend_keymap = [
          {
            on = [ "n" ];
            run = "plugin bookmarks save";
            desc = "Save current position as a bookmark";
          }
          {
            on = [ "'" ];
            run = "plugin bookmarks jump";
            desc = "Jump to a bookmark";
          }
          {
            on = [
              "b"
              "d"
            ];
            run = "plugin bookmarks delete";
            desc = "Delete a bookmark";
          }
          {
            on = [
              "b"
              "D"
            ];
            run = "plugin bookmarks delete_all";
            desc = "Delete all bookmarks";
          }
        ];
      };
    };
    plugins = {
      bookmarks = pkgs.yaziPlugins.bookmarks.overrideAttrs (oldAttrs: {
        src = pkgs.fetchFromGitHub {
          owner = "sidhantunnithan";
          repo = "bookmarks.yazi";
          rev = "a61e524a2b74f8f09e5af2265df0a32605f7528c";
          sha256 = "u5AtP6Mp6OwLQps10PNV1xjwjwfDmZxND0NDnIuqZRY=";
        };
      });
    };
  };
}