Roundcube with plugins

Hi everyone. I’m looking to migrate my couple of years old roundcube setup to NixOS. I’ve managed to import and upgrade the database but what I’m stuck on is: modules. On my old Roundcube setup I had a lot of those and I’m not certain how to get this done on NixOS.

We have services.roundcube.plugins with the description:

List of roundcube plugins to enable. Currently, only those directly shipped with Roundcube are supported.

There also is services.roundcube.package with the following description:

The package which contains roundcube’s sources. Can be overriden to create an environment which contains roundcube and third-party plugins.

Type: package
Default: pkgs.roundcube
Example: roundcube.withPlugins (plugins: [ plugins.persistent_login ])

Honestly I have no idea how to get started with this. One of the useful plugins my old setup is using is the right click context menu and yet another one is the twofactor gauthenticator plugin.

How can I include these plugins into my roundcube setup? Where do I start?

1 Like

I’m not roundcube user, but from documentation I can say:

Good news and bad news:
Good:
Context menu is already packed, this should give you a basic

{pkgs, ...}:
{
  services.roundcube.enable  = true;
  services.roundcube.plugins = [ "contextmenu" ];
  services.roundcube.package = pkgs.roundcube.withPlugins (
    plugins: [ plugins.contextmenu ]
  );
}

You can search for already packed plugins in search.nixos.org

Bad:
Two factor isn’t packed yet, that means you have to create a package like someone did for contextmenu and others

If other plugins are simple like contextmenu or custom_from whould be like this:

{pkgs, ...}:
let custom_from = pkgs.roundcubePlugin rec {
  pname   = "custom_from";
  version = "1.6.6";
  src     = pkgs.fetchzip {
    url  = "https://github.com/r3c/custom_from/archive/refs/tags/${version}.zip";
    hash = "sha256-QvMYwFWY0BZOkzhDtW7XJ77i5mVkDNAiN4JBdsCuUy0=";
  };
}
in 
{
  services.roundcube.enable  = true;
  services.roundcube.plugins = [ "contextmenu" "custom_from"];
  services.roundcube.package = pkgs.roundcube.withPlugins (
    plugins: [ plugins.contextmenu custom_from ]
  );
}
2 Likes

Hi @hugosenari thanks for your suggestions. I finally got around to testing this.

I tried your example but it told me that pkgs.roundcubePlugin doesn’t exist, so I assumed you meant pkgs.roundcubePlugins, but when using that I am getting the following error:

building the system configuration...
warning: Git tree '/home/markvd/user/mozart' is dirty
error: attempt to call something which is not a function but a set

       at /nix/store/i5z77x6xa1n77zi07jxdd93v1jxlr5c6-source/nixos/service/roundcube.nix:5:19:

            4|   let
            5|     custom_from = pkgs.roundcubePlugins rec {
             |                   ^
            6|       pname   = "custom_from";
(use '--show-trace' to show detailed location information)

Any idea how I should handle this?
EDIT: I figured out that it works when I use pkgs.roundcubePlugins.roundcubePlugin. With that, this works very well. Much thanks! :smiley_cat:

Roundcube maintainer here. It’s pkgs.roundcubePlugins.roundcubePlugin. Does that fix your issue? %)

2 Likes

Hi @Ma27 yess I just found it with some help in the repl (the tab key, specifically :laughing:)

Much thanks, it works now :slightly_smiling_face: :+1:

2 Likes

Please PR your plugins pkgs to nixpkgs :wink:

1 Like

Ok! Will do. No problem.

I’ve successfully implement the 2FA (it seems to a bit broken with the newest theme) plugin.
However it doesn’t really have a version number.
Could I provide the PR in the following style?

In case it isn’t obvious, I believe the plugins “packaged with roundcube” are the ones in this git subdir: https://github.com/roundcube/roundcubemail/tree/master/plugins

E.g. managesieve

Update:

Looks like "managesieve" and "archive" plugins work OOTB, however some other plugins need the withPlugins treatment from the comment above:

  services.roundcube.package = pkgs.roundcube.withPlugins (
    plugins: [ plugins.contextmenu custom_from ]
  );

I suppose the withPlugins treatment is necessary for the plugins shown here: https://github.com/NixOS/nixpkgs/tree/master/pkgs/servers/roundcube/plugins

Sidenote: the carddav plugin needs additional configuration as it does not work OOTB, haven’t figured that one out yet