3
0
Fork 0
forked from mirrors/nixpkgs

nixos/matrix-synapse: make home directory configurable

This commit is contained in:
Ruben Maher 2017-11-19 09:45:52 +10:30
parent 7be9c9c95f
commit 86e161ff47

View file

@ -44,7 +44,7 @@ database: {
} }
event_cache_size: "${cfg.event_cache_size}" event_cache_size: "${cfg.event_cache_size}"
verbose: ${cfg.verbose} verbose: ${cfg.verbose}
log_file: "/var/log/matrix-synapse/homeserver.log" log_file: "${cfg.dataDir}/homeserver.log"
log_config: "${logConfigFile}" log_config: "${logConfigFile}"
rc_messages_per_second: ${cfg.rc_messages_per_second} rc_messages_per_second: ${cfg.rc_messages_per_second}
rc_message_burst_count: ${cfg.rc_message_burst_count} rc_message_burst_count: ${cfg.rc_message_burst_count}
@ -53,8 +53,8 @@ federation_rc_sleep_limit: ${cfg.federation_rc_sleep_limit}
federation_rc_sleep_delay: ${cfg.federation_rc_sleep_delay} federation_rc_sleep_delay: ${cfg.federation_rc_sleep_delay}
federation_rc_reject_limit: ${cfg.federation_rc_reject_limit} federation_rc_reject_limit: ${cfg.federation_rc_reject_limit}
federation_rc_concurrent: ${cfg.federation_rc_concurrent} federation_rc_concurrent: ${cfg.federation_rc_concurrent}
media_store_path: "/var/lib/matrix-synapse/media" media_store_path: "${cfg.dataDir}/media"
uploads_path: "/var/lib/matrix-synapse/uploads" uploads_path: "${cfg.dataDir}/uploads"
max_upload_size: "${cfg.max_upload_size}" max_upload_size: "${cfg.max_upload_size}"
max_image_pixels: "${cfg.max_image_pixels}" max_image_pixels: "${cfg.max_image_pixels}"
dynamic_thumbnails: ${boolToString cfg.dynamic_thumbnails} dynamic_thumbnails: ${boolToString cfg.dynamic_thumbnails}
@ -86,7 +86,7 @@ ${optionalString (cfg.macaroon_secret_key != null) ''
expire_access_token: ${boolToString cfg.expire_access_token} expire_access_token: ${boolToString cfg.expire_access_token}
enable_metrics: ${boolToString cfg.enable_metrics} enable_metrics: ${boolToString cfg.enable_metrics}
report_stats: ${boolToString cfg.report_stats} report_stats: ${boolToString cfg.report_stats}
signing_key_path: "/var/lib/matrix-synapse/homeserver.signing.key" signing_key_path: "${cfg.dataDir}/homeserver.signing.key"
key_refresh_interval: "${cfg.key_refresh_interval}" key_refresh_interval: "${cfg.key_refresh_interval}"
perspectives: perspectives:
servers: { servers: {
@ -348,7 +348,7 @@ in {
database_args = mkOption { database_args = mkOption {
type = types.attrs; type = types.attrs;
default = { default = {
database = "/var/lib/matrix-synapse/homeserver.db"; database = "${cfg.dataDir}/homeserver.db";
}; };
description = '' description = ''
Arguments to pass to the engine. Arguments to pass to the engine.
@ -586,6 +586,14 @@ in {
A yaml python logging config file A yaml python logging config file
''; '';
}; };
dataDir = mkOption {
type = types.str;
default = "/var/lib/matrix-synapse";
description = ''
The directory where matrix-synapse stores its stateful data such as
certificates, media and uploads.
'';
};
}; };
}; };
@ -593,7 +601,7 @@ in {
users.extraUsers = [ users.extraUsers = [
{ name = "matrix-synapse"; { name = "matrix-synapse";
group = "matrix-synapse"; group = "matrix-synapse";
home = "/var/lib/matrix-synapse"; home = cfg.dataDir;
createHome = true; createHome = true;
shell = "${pkgs.bash}/bin/bash"; shell = "${pkgs.bash}/bin/bash";
uid = config.ids.uids.matrix-synapse; uid = config.ids.uids.matrix-synapse;
@ -611,16 +619,16 @@ in {
preStart = '' preStart = ''
${cfg.package}/bin/homeserver \ ${cfg.package}/bin/homeserver \
--config-path ${configFile} \ --config-path ${configFile} \
--keys-directory /var/lib/matrix-synapse \ --keys-directory ${cfg.dataDir} \
--generate-keys --generate-keys
''; '';
serviceConfig = { serviceConfig = {
Type = "simple"; Type = "simple";
User = "matrix-synapse"; User = "matrix-synapse";
Group = "matrix-synapse"; Group = "matrix-synapse";
WorkingDirectory = "/var/lib/matrix-synapse"; WorkingDirectory = cfg.dataDir;
PermissionsStartOnly = true; PermissionsStartOnly = true;
ExecStart = "${cfg.package}/bin/homeserver --config-path ${configFile} --keys-directory /var/lib/matrix-synapse"; ExecStart = "${cfg.package}/bin/homeserver --config-path ${configFile} --keys-directory ${cfg.dataDir}";
Restart = "on-failure"; Restart = "on-failure";
}; };
}; };