diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 15fa7b1ac36a..75e8446523f9 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -332,6 +332,7 @@ ./services/mail/rspamd.nix ./services/mail/rss2email.nix ./services/mail/rmilter.nix + ./services/mail/roundcube.nix ./services/mail/nullmailer.nix ./services/misc/airsonic.nix ./services/misc/apache-kafka.nix diff --git a/nixos/modules/services/mail/roundcube.nix b/nixos/modules/services/mail/roundcube.nix new file mode 100644 index 000000000000..6d81c7374f4d --- /dev/null +++ b/nixos/modules/services/mail/roundcube.nix @@ -0,0 +1,153 @@ +{ lib, config, pkgs, ... }: + +with lib; + +let + cfg = config.services.roundcube; +in +{ + options.services.roundcube = { + enable = mkOption { + type = types.bool; + default = false; + description = '' + Whether to enable roundcube. + + Also enables nginx virtual host management. + Further nginx configuration can be done by adapting services.nginx.virtualHosts.<name>. + See for further information. + ''; + }; + + hostName = mkOption { + type = types.str; + example = "webmail.example.com"; + description = "Hostname to use for the nginx vhost"; + }; + + database = { + username = mkOption { + type = types.str; + default = "roundcube"; + description = "Username for the postgresql connection"; + }; + host = mkOption { + type = types.str; + default = "localhost"; + description = '' + Host of the postgresql server. If this is not set to + localhost, you have to create the + postgresql user and database yourself, with appropriate + permissions. + ''; + }; + password = mkOption { + type = types.str; + description = "Password for the postgresql connection"; + }; + dbname = mkOption { + type = types.str; + default = "roundcube"; + description = "Name of the postgresql database"; + }; + }; + + plugins = mkOption { + type = types.listOf types.str; + default = []; + description = '' + List of roundcube plugins to enable. Currently, only those directly shipped with Roundcube are supported. + ''; + }; + + extraConfig = mkOption { + type = types.lines; + default = ""; + description = "Extra configuration for roundcube webmail instance"; + }; + }; + + config = mkIf cfg.enable { + environment.etc."roundcube/config.inc.php".text = '' + start; + $roundcube->waitForUnit("postgresql.service"); + $roundcube->waitForUnit("phpfpm-roundcube.service"); + $roundcube->waitForUnit("nginx.service"); + $roundcube->succeed("curl -sSfL http://roundcube/"); + ''; +})