2018-10-01 16:12:56 +01:00
|
|
|
{ lib, config, pkgs, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.services.roundcube;
|
2019-08-08 03:36:49 +01:00
|
|
|
fpm = config.services.phpfpm.pools.roundcube;
|
2020-01-05 12:00:00 +00:00
|
|
|
localDB = cfg.database.host == "localhost";
|
|
|
|
user = cfg.database.username;
|
2024-04-21 22:18:41 +01:00
|
|
|
phpWithPspell = pkgs.php83.withExtensions ({ enabled, all }: [ all.pspell ] ++ enabled);
|
2018-10-01 16:12:56 +01:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options.services.roundcube = {
|
2024-08-24 21:05:35 +01:00
|
|
|
enable = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
2018-11-28 16:33:26 +00:00
|
|
|
default = false;
|
2018-10-11 09:09:29 +01:00
|
|
|
description = ''
|
2018-11-28 16:33:26 +00:00
|
|
|
Whether to enable roundcube.
|
|
|
|
|
|
|
|
Also enables nginx virtual host management.
|
2018-10-11 09:09:29 +01:00
|
|
|
Further nginx configuration can be done by adapting `services.nginx.virtualHosts.<name>`.
|
|
|
|
See [](#opt-services.nginx.virtualHosts) for further information.
|
|
|
|
'';
|
2018-10-01 16:12:56 +01:00
|
|
|
};
|
|
|
|
|
2024-08-24 21:05:35 +01:00
|
|
|
hostName = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2018-11-28 16:33:26 +00:00
|
|
|
example = "webmail.example.com";
|
|
|
|
description = "Hostname to use for the nginx vhost";
|
2018-10-01 16:12:56 +01:00
|
|
|
};
|
|
|
|
|
2024-08-24 21:05:35 +01:00
|
|
|
package = lib.mkPackageOption pkgs "roundcube" {
|
2023-11-27 00:19:27 +00:00
|
|
|
example = "roundcube.withPlugins (plugins: [ plugins.persistent_login ])";
|
2019-01-31 21:45:14 +00:00
|
|
|
};
|
|
|
|
|
2018-10-11 09:09:29 +01:00
|
|
|
database = {
|
2024-08-24 21:05:35 +01:00
|
|
|
username = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2018-10-11 09:09:29 +01:00
|
|
|
default = "roundcube";
|
2020-01-05 12:00:00 +00:00
|
|
|
description = ''
|
|
|
|
Username for the postgresql connection.
|
|
|
|
If `database.host` is set to `localhost`, a unix user and group of the same name will be created as well.
|
|
|
|
'';
|
2018-10-11 09:09:29 +01:00
|
|
|
};
|
2024-08-24 21:05:35 +01:00
|
|
|
host = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2018-10-11 09:09:29 +01:00
|
|
|
default = "localhost";
|
2018-11-28 16:33:26 +00:00
|
|
|
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.
|
|
|
|
'';
|
2018-10-11 09:09:29 +01:00
|
|
|
};
|
2024-08-24 21:05:35 +01:00
|
|
|
password = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2020-01-05 12:00:00 +00:00
|
|
|
description = "Password for the postgresql connection. Do not use: the password will be stored world readable in the store; use `passwordFile` instead.";
|
|
|
|
default = "";
|
|
|
|
};
|
2024-08-24 21:05:35 +01:00
|
|
|
passwordFile = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2023-04-23 13:05:40 +01:00
|
|
|
description = ''
|
|
|
|
Password file for the postgresql connection.
|
2023-05-20 03:11:38 +01:00
|
|
|
Must be formatted according to PostgreSQL .pgpass standard (see https://www.postgresql.org/docs/current/libpq-pgpass.html)
|
2023-04-23 19:28:00 +01:00
|
|
|
but only one line, no comments and readable by user `nginx`.
|
|
|
|
Ignored if `database.host` is set to `localhost`, as peer authentication will be used.
|
2023-04-23 13:05:40 +01:00
|
|
|
'';
|
2018-10-11 09:09:29 +01:00
|
|
|
};
|
2024-08-24 21:05:35 +01:00
|
|
|
dbname = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2018-10-11 09:09:29 +01:00
|
|
|
default = "roundcube";
|
|
|
|
description = "Name of the postgresql database";
|
|
|
|
};
|
|
|
|
};
|
2018-10-01 16:12:56 +01:00
|
|
|
|
2024-08-24 21:05:35 +01:00
|
|
|
plugins = lib.mkOption {
|
|
|
|
type = lib.types.listOf lib.types.str;
|
2018-10-11 09:09:29 +01:00
|
|
|
default = [];
|
|
|
|
description = ''
|
2018-11-28 16:33:26 +00:00
|
|
|
List of roundcube plugins to enable. Currently, only those directly shipped with Roundcube are supported.
|
2018-10-01 16:12:56 +01:00
|
|
|
'';
|
2018-10-11 09:09:29 +01:00
|
|
|
};
|
|
|
|
|
2024-08-24 21:05:35 +01:00
|
|
|
dicts = lib.mkOption {
|
|
|
|
type = lib.types.listOf lib.types.package;
|
2020-04-10 13:00:00 +01:00
|
|
|
default = [];
|
2024-08-24 21:05:35 +01:00
|
|
|
example = lib.literalExpression "with pkgs.aspellDicts; [ en fr de ]";
|
2020-04-10 13:00:00 +01:00
|
|
|
description = ''
|
2022-12-18 00:31:14 +00:00
|
|
|
List of aspell dictionaries for spell checking. If empty, spell checking is disabled.
|
2020-04-10 13:00:00 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-08-24 21:05:35 +01:00
|
|
|
maxAttachmentSize = lib.mkOption {
|
|
|
|
type = lib.types.int;
|
2020-07-05 10:40:15 +01:00
|
|
|
default = 18;
|
2024-07-04 17:51:32 +01:00
|
|
|
apply = configuredMaxAttachmentSize: "${toString (configuredMaxAttachmentSize * 1.37)}M";
|
2020-07-05 10:40:15 +01:00
|
|
|
description = ''
|
2020-07-08 10:09:01 +01:00
|
|
|
The maximum attachment size in MB.
|
2024-07-04 17:51:32 +01:00
|
|
|
[upstream issue comment]: https://github.com/roundcube/roundcubemail/issues/7979#issuecomment-808879209
|
|
|
|
::: {.note}
|
|
|
|
Since there is some overhead in base64 encoding applied to attachments, + 37% will be added
|
|
|
|
to the value set in this option in order to offset the overhead. For example, setting
|
|
|
|
`maxAttachmentSize` to `100` would result in `137M` being the real value in the configuration.
|
|
|
|
See [upstream issue comment] for more details on the motivations behind this.
|
|
|
|
:::
|
2020-07-05 10:40:15 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-12-25 21:10:01 +00:00
|
|
|
configureNginx = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
|
|
|
default = true;
|
|
|
|
description = "Configure nginx as a reverse proxy for roundcube.";
|
|
|
|
};
|
|
|
|
|
2024-08-24 21:05:35 +01:00
|
|
|
extraConfig = lib.mkOption {
|
|
|
|
type = lib.types.lines;
|
2018-10-11 09:09:29 +01:00
|
|
|
default = "";
|
|
|
|
description = "Extra configuration for roundcube webmail instance";
|
2018-10-01 16:12:56 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-08-24 21:05:35 +01:00
|
|
|
config = lib.mkIf cfg.enable {
|
2020-01-05 12:00:00 +00:00
|
|
|
# backward compatibility: if password is set but not passwordFile, make one.
|
2024-08-24 21:05:35 +01:00
|
|
|
services.roundcube.database.passwordFile = lib.mkIf (!localDB && cfg.database.password != "") (lib.mkDefault ("${pkgs.writeText "roundcube-password" cfg.database.password}"));
|
2020-01-05 12:00:00 +00:00
|
|
|
warnings = lib.optional (!localDB && cfg.database.password != "") "services.roundcube.database.password is deprecated and insecure; use services.roundcube.database.passwordFile instead";
|
|
|
|
|
2018-10-11 09:09:29 +01:00
|
|
|
environment.etc."roundcube/config.inc.php".text = ''
|
|
|
|
<?php
|
2018-10-01 16:12:56 +01:00
|
|
|
|
2023-04-23 10:35:04 +01:00
|
|
|
${lib.optionalString (!localDB) ''
|
2023-04-23 19:28:00 +01:00
|
|
|
$password = file('${cfg.database.passwordFile}')[0];
|
2023-04-23 10:35:04 +01:00
|
|
|
$password = preg_split('~\\\\.(*SKIP)(*FAIL)|\:~s', $password);
|
2023-11-10 23:17:53 +00:00
|
|
|
$password = rtrim(end($password));
|
2023-04-23 10:35:04 +01:00
|
|
|
$password = str_replace("\\:", ":", $password);
|
|
|
|
$password = str_replace("\\\\", "\\", $password);
|
|
|
|
''}
|
2020-01-05 12:00:00 +00:00
|
|
|
|
2018-10-11 09:09:29 +01:00
|
|
|
$config = array();
|
2020-01-05 12:00:00 +00:00
|
|
|
$config['db_dsnw'] = 'pgsql://${cfg.database.username}${lib.optionalString (!localDB) ":' . $password . '"}@${if localDB then "unix(/run/postgresql)" else cfg.database.host}/${cfg.database.dbname}';
|
2018-10-11 09:09:29 +01:00
|
|
|
$config['log_driver'] = 'syslog';
|
2020-07-05 10:40:15 +01:00
|
|
|
$config['max_message_size'] = '${cfg.maxAttachmentSize}';
|
2024-08-24 21:05:35 +01:00
|
|
|
$config['plugins'] = [${lib.concatMapStringsSep "," (p: "'${p}'") cfg.plugins}];
|
2020-01-05 12:00:00 +00:00
|
|
|
$config['des_key'] = file_get_contents('/var/lib/roundcube/des_key');
|
2020-01-05 12:00:00 +00:00
|
|
|
$config['mime_types'] = '${pkgs.nginx}/conf/mime.types';
|
2023-03-17 12:14:57 +00:00
|
|
|
# Roundcube uses PHP-FPM which has `PrivateTmp = true;`
|
|
|
|
$config['temp_dir'] = '/tmp';
|
2020-04-10 13:00:00 +01:00
|
|
|
$config['enable_spellcheck'] = ${if cfg.dicts == [] then "false" else "true"};
|
|
|
|
# by default, spellchecking uses a third-party cloud services
|
|
|
|
$config['spellcheck_engine'] = 'pspell';
|
|
|
|
$config['spellcheck_languages'] = array(${lib.concatMapStringsSep ", " (dict: let p = builtins.parseDrvName dict.shortName; in "'${p.name}' => '${dict.fullName}'") cfg.dicts});
|
|
|
|
|
2018-10-11 09:09:29 +01:00
|
|
|
${cfg.extraConfig}
|
|
|
|
'';
|
|
|
|
|
2023-12-25 21:10:01 +00:00
|
|
|
services.nginx = lib.mkIf cfg.configureNginx {
|
2018-10-11 09:09:29 +01:00
|
|
|
enable = true;
|
|
|
|
virtualHosts = {
|
|
|
|
${cfg.hostName} = {
|
2024-08-24 21:05:35 +01:00
|
|
|
forceSSL = lib.mkDefault true;
|
|
|
|
enableACME = lib.mkDefault true;
|
2023-12-24 15:50:05 +00:00
|
|
|
root = cfg.package;
|
2018-10-11 09:09:29 +01:00
|
|
|
locations."/" = {
|
|
|
|
index = "index.php";
|
2023-12-24 15:50:05 +00:00
|
|
|
priority = 1100;
|
2018-10-11 09:09:29 +01:00
|
|
|
extraConfig = ''
|
2023-12-24 15:50:05 +00:00
|
|
|
add_header Cache-Control 'public, max-age=604800, must-revalidate';
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
locations."~ ^/(SQL|bin|config|logs|temp|vendor)/" = {
|
|
|
|
priority = 3110;
|
|
|
|
extraConfig = ''
|
|
|
|
return 404;
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
locations."~ ^/(CHANGELOG.md|INSTALL|LICENSE|README.md|SECURITY.md|UPGRADING|composer.json|composer.lock)" = {
|
|
|
|
priority = 3120;
|
|
|
|
extraConfig = ''
|
|
|
|
return 404;
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
locations."~* \\.php(/|$)" = {
|
|
|
|
priority = 3130;
|
|
|
|
extraConfig = ''
|
|
|
|
fastcgi_pass unix:${fpm.socket};
|
|
|
|
fastcgi_param PATH_INFO $fastcgi_path_info;
|
|
|
|
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
|
|
|
include ${config.services.nginx.package}/conf/fastcgi.conf;
|
2018-10-11 09:09:29 +01:00
|
|
|
'';
|
|
|
|
};
|
2018-10-01 16:12:56 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
nixos/postgresql: drop ensurePermissions, fix ensureUsers for postgresql15
Closes #216989
First of all, a bit of context: in PostgreSQL, newly created users don't
have the CREATE privilege on the public schema of a database even with
`ALL PRIVILEGES` granted via `ensurePermissions` which is how most of
the DB users are currently set up "declaratively"[1]. This means e.g. a
freshly deployed Nextcloud service will break early because Nextcloud
itself cannot CREATE any tables in the public schema anymore.
The other issue here is that `ensurePermissions` is a mere hack. It's
effectively a mixture of SQL code (e.g. `DATABASE foo` is relying on how
a value is substituted in a query. You'd have to parse a subset of SQL
to actually know which object are permissions granted to for a user).
After analyzing the existing modules I realized that in every case with
a single exception[2] the UNIX system user is equal to the db user is
equal to the db name and I don't see a compelling reason why people
would change that in 99% of the cases. In fact, some modules would even
break if you'd change that because the declarations of the system user &
the db user are mixed up[3].
So I decided to go with something new which restricts the ways to use
`ensure*` options rather than expanding those[4]. Effectively this means
that
* The DB user _must_ be equal to the DB name.
* Permissions are granted via `ensureDBOwnerhip` for an attribute-set in
`ensureUsers`. That way, the user is actually the owner and can
perform `CREATE`.
* For such a postgres user, a database must be declared in
`ensureDatabases`.
For anything else, a custom state management should be implemented. This
can either be `initialScript`, doing it manual, outside of the module or
by implementing proper state management for postgresql[5], but the
current state of `ensure*` isn't even declarative, but a convergent tool
which is what Nix actually claims to _not_ do.
Regarding existing setups: there are effectively two options:
* Leave everything as-is (assuming that system user == db user == db
name): then the DB user will automatically become the DB owner and
everything else stays the same.
* Drop the `createDatabase = true;` declarations: nothing will change
because a removal of `ensure*` statements is ignored, so it doesn't
matter at all whether this option is kept after the first deploy (and
later on you'd usually restore from backups anyways).
The DB user isn't the owner of the DB then, but for an existing setup
this is irrelevant because CREATE on the public schema isn't revoked
from existing users (only not granted for new users).
[1] not really declarative though because removals of these statements
are simply ignored for instance: https://github.com/NixOS/nixpkgs/issues/206467
[2] `services.invidious`: I removed the `ensure*` part temporarily
because it IMHO falls into the category "manage the state on your
own" (see the commit message). See also
https://github.com/NixOS/nixpkgs/pull/265857
[3] e.g. roundcube had `"DATABASE ${cfg.database.username}" = "ALL PRIVILEGES";`
[4] As opposed to other changes that are considered a potential fix, but
also add more things like collation for DBs or passwords that are
_never_ touched again when changing those.
[5] As suggested in e.g. https://github.com/NixOS/nixpkgs/issues/206467
2023-11-08 11:50:09 +00:00
|
|
|
assertions = [
|
|
|
|
{
|
|
|
|
assertion = localDB -> cfg.database.username == cfg.database.dbname;
|
|
|
|
message = ''
|
|
|
|
When setting up a DB and its owner user, the owner and the DB name must be
|
|
|
|
equal!
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2024-08-24 21:05:35 +01:00
|
|
|
services.postgresql = lib.mkIf localDB {
|
2018-10-11 09:09:29 +01:00
|
|
|
enable = true;
|
2020-01-05 12:00:00 +00:00
|
|
|
ensureDatabases = [ cfg.database.dbname ];
|
|
|
|
ensureUsers = [ {
|
|
|
|
name = cfg.database.username;
|
nixos/postgresql: drop ensurePermissions, fix ensureUsers for postgresql15
Closes #216989
First of all, a bit of context: in PostgreSQL, newly created users don't
have the CREATE privilege on the public schema of a database even with
`ALL PRIVILEGES` granted via `ensurePermissions` which is how most of
the DB users are currently set up "declaratively"[1]. This means e.g. a
freshly deployed Nextcloud service will break early because Nextcloud
itself cannot CREATE any tables in the public schema anymore.
The other issue here is that `ensurePermissions` is a mere hack. It's
effectively a mixture of SQL code (e.g. `DATABASE foo` is relying on how
a value is substituted in a query. You'd have to parse a subset of SQL
to actually know which object are permissions granted to for a user).
After analyzing the existing modules I realized that in every case with
a single exception[2] the UNIX system user is equal to the db user is
equal to the db name and I don't see a compelling reason why people
would change that in 99% of the cases. In fact, some modules would even
break if you'd change that because the declarations of the system user &
the db user are mixed up[3].
So I decided to go with something new which restricts the ways to use
`ensure*` options rather than expanding those[4]. Effectively this means
that
* The DB user _must_ be equal to the DB name.
* Permissions are granted via `ensureDBOwnerhip` for an attribute-set in
`ensureUsers`. That way, the user is actually the owner and can
perform `CREATE`.
* For such a postgres user, a database must be declared in
`ensureDatabases`.
For anything else, a custom state management should be implemented. This
can either be `initialScript`, doing it manual, outside of the module or
by implementing proper state management for postgresql[5], but the
current state of `ensure*` isn't even declarative, but a convergent tool
which is what Nix actually claims to _not_ do.
Regarding existing setups: there are effectively two options:
* Leave everything as-is (assuming that system user == db user == db
name): then the DB user will automatically become the DB owner and
everything else stays the same.
* Drop the `createDatabase = true;` declarations: nothing will change
because a removal of `ensure*` statements is ignored, so it doesn't
matter at all whether this option is kept after the first deploy (and
later on you'd usually restore from backups anyways).
The DB user isn't the owner of the DB then, but for an existing setup
this is irrelevant because CREATE on the public schema isn't revoked
from existing users (only not granted for new users).
[1] not really declarative though because removals of these statements
are simply ignored for instance: https://github.com/NixOS/nixpkgs/issues/206467
[2] `services.invidious`: I removed the `ensure*` part temporarily
because it IMHO falls into the category "manage the state on your
own" (see the commit message). See also
https://github.com/NixOS/nixpkgs/pull/265857
[3] e.g. roundcube had `"DATABASE ${cfg.database.username}" = "ALL PRIVILEGES";`
[4] As opposed to other changes that are considered a potential fix, but
also add more things like collation for DBs or passwords that are
_never_ touched again when changing those.
[5] As suggested in e.g. https://github.com/NixOS/nixpkgs/issues/206467
2023-11-08 11:50:09 +00:00
|
|
|
ensureDBOwnership = true;
|
2020-01-05 12:00:00 +00:00
|
|
|
} ];
|
2018-10-11 09:09:29 +01:00
|
|
|
};
|
|
|
|
|
2024-08-24 21:05:35 +01:00
|
|
|
users.users.${user} = lib.mkIf localDB {
|
2020-01-05 12:00:00 +00:00
|
|
|
group = user;
|
|
|
|
isSystemUser = true;
|
|
|
|
createHome = false;
|
|
|
|
};
|
2024-08-24 21:05:35 +01:00
|
|
|
users.groups.${user} = lib.mkIf localDB {};
|
2020-01-05 12:00:00 +00:00
|
|
|
|
2019-07-03 17:11:38 +01:00
|
|
|
services.phpfpm.pools.roundcube = {
|
2020-01-05 12:00:00 +00:00
|
|
|
user = if localDB then user else "nginx";
|
2019-08-08 03:36:49 +01:00
|
|
|
phpOptions = ''
|
|
|
|
error_log = 'stderr'
|
|
|
|
log_errors = on
|
2020-07-05 10:40:15 +01:00
|
|
|
post_max_size = ${cfg.maxAttachmentSize}
|
|
|
|
upload_max_filesize = ${cfg.maxAttachmentSize}
|
2019-07-03 17:11:38 +01:00
|
|
|
'';
|
2024-08-24 21:05:35 +01:00
|
|
|
settings = lib.mapAttrs (name: lib.mkDefault) {
|
2019-08-08 03:36:49 +01:00
|
|
|
"listen.owner" = "nginx";
|
|
|
|
"listen.group" = "nginx";
|
|
|
|
"listen.mode" = "0660";
|
|
|
|
"pm" = "dynamic";
|
|
|
|
"pm.max_children" = 75;
|
|
|
|
"pm.start_servers" = 2;
|
|
|
|
"pm.min_spare_servers" = 1;
|
|
|
|
"pm.max_spare_servers" = 20;
|
|
|
|
"pm.max_requests" = 500;
|
|
|
|
"catch_workers_output" = true;
|
|
|
|
};
|
2020-04-10 13:00:00 +01:00
|
|
|
phpPackage = phpWithPspell;
|
|
|
|
phpEnv.ASPELL_CONF = "dict-dir ${pkgs.aspellWithDicts (_: cfg.dicts)}/lib/aspell";
|
2019-07-03 17:11:38 +01:00
|
|
|
};
|
2018-10-11 09:09:29 +01:00
|
|
|
systemd.services.phpfpm-roundcube.after = [ "roundcube-setup.service" ];
|
|
|
|
|
2020-11-08 21:20:18 +00:00
|
|
|
# Restart on config changes.
|
|
|
|
systemd.services.phpfpm-roundcube.restartTriggers = [
|
|
|
|
config.environment.etc."roundcube/config.inc.php".source
|
|
|
|
];
|
|
|
|
|
2024-08-24 21:05:35 +01:00
|
|
|
systemd.services.roundcube-setup = lib.mkMerge [
|
|
|
|
(lib.mkIf (cfg.database.host == "localhost") {
|
2019-04-02 15:02:53 +01:00
|
|
|
requires = [ "postgresql.service" ];
|
|
|
|
after = [ "postgresql.service" ];
|
|
|
|
})
|
|
|
|
{
|
2023-10-04 07:23:30 +01:00
|
|
|
wants = [ "network-online.target" ];
|
2023-04-23 11:16:43 +01:00
|
|
|
after = [ "network-online.target" ];
|
2019-04-02 15:02:53 +01:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
2024-01-01 19:41:59 +00:00
|
|
|
|
|
|
|
path = [ config.services.postgresql.package ];
|
2020-01-05 12:00:00 +00:00
|
|
|
script = let
|
2024-01-01 19:41:59 +00:00
|
|
|
psql = "${lib.optionalString (!localDB) "PGPASSFILE=${cfg.database.passwordFile}"} psql ${lib.optionalString (!localDB) "-h ${cfg.database.host} -U ${cfg.database.username} "} ${cfg.database.dbname}";
|
2020-01-05 12:00:00 +00:00
|
|
|
in
|
|
|
|
''
|
|
|
|
version="$(${psql} -t <<< "select value from system where name = 'roundcube-version';" || true)"
|
|
|
|
if ! (grep -E '[a-zA-Z0-9]' <<< "$version"); then
|
|
|
|
${psql} -f ${cfg.package}/SQL/postgres.initial.sql
|
2018-10-11 09:09:29 +01:00
|
|
|
fi
|
2018-11-28 16:33:26 +00:00
|
|
|
|
2020-01-05 12:00:00 +00:00
|
|
|
if [ ! -f /var/lib/roundcube/des_key ]; then
|
|
|
|
base64 /dev/urandom | head -c 24 > /var/lib/roundcube/des_key;
|
|
|
|
# we need to log out everyone in case change the des_key
|
|
|
|
# from the default when upgrading from nixos 19.09
|
|
|
|
${psql} <<< 'TRUNCATE TABLE session;'
|
|
|
|
fi
|
|
|
|
|
2020-04-10 13:00:00 +01:00
|
|
|
${phpWithPspell}/bin/php ${cfg.package}/bin/update.sh
|
2019-04-02 15:02:53 +01:00
|
|
|
'';
|
2020-01-05 12:00:00 +00:00
|
|
|
serviceConfig = {
|
|
|
|
Type = "oneshot";
|
|
|
|
StateDirectory = "roundcube";
|
|
|
|
User = if localDB then user else "nginx";
|
2020-01-05 12:00:00 +00:00
|
|
|
# so that the des_key is not world readable
|
|
|
|
StateDirectoryMode = "0700";
|
2020-01-05 12:00:00 +00:00
|
|
|
};
|
2019-04-02 15:02:53 +01:00
|
|
|
}
|
|
|
|
];
|
2018-10-01 16:12:56 +01:00
|
|
|
};
|
|
|
|
}
|