Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/matrix-sliding-sync: add dependency on matrix-synapse if running locally #265071

Merged
merged 3 commits into from
Nov 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions nixos/modules/services/matrix/appservice-discord.nix
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ in {

serviceDependencies = mkOption {
type = with types; listOf str;
default = optional config.services.matrix-synapse.enable "matrix-synapse.service";
default = optional config.services.matrix-synapse.enable config.services.matrix-synapse.serviceUnit;
defaultText = literalExpression ''
optional config.services.matrix-synapse.enable "matrix-synapse.service"
optional config.services.matrix-synapse.enable config.services.matrix-synapse.serviceUnit
'';
description = lib.mdDoc ''
List of Systemd services to require and wait for when starting the application service,
Expand Down
9 changes: 7 additions & 2 deletions nixos/modules/services/matrix/matrix-sliding-sync.nix
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,11 @@ in
} ];
};

systemd.services.matrix-sliding-sync = {
after = lib.optional cfg.createDatabase "postgresql.service";
systemd.services.matrix-sliding-sync = rec {
after =
lib.optional cfg.createDatabase "postgresql.service"
++ lib.optional config.services.matrix-synapse.enable config.services.matrix-synapse.serviceUnit;
wants = after;
Ma27 marked this conversation as resolved.
Show resolved Hide resolved
wantedBy = [ "multi-user.target" ];
environment = cfg.settings;
serviceConfig = {
Expand All @@ -90,6 +93,8 @@ in
ExecStart = lib.getExe cfg.package;
StateDirectory = "matrix-sliding-sync";
WorkingDirectory = "%S/matrix-sliding-sync";
Restart = "on-failure";
RestartSec = "1s";
};
};
};
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/matrix/mautrix-facebook.nix
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ in {
wantedBy = [ "multi-user.target" ];
wants = [
"network-online.target"
] ++ optional config.services.matrix-synapse.enable "matrix-synapse.service"
] ++ optional config.services.matrix-synapse.enable config.services.matrix-synapse.serviceUnit
++ optional cfg.configurePostgresql "postgresql.service";
after = wants;

Expand Down
4 changes: 2 additions & 2 deletions nixos/modules/services/matrix/mautrix-telegram.nix
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ in {

serviceDependencies = mkOption {
type = with types; listOf str;
default = optional config.services.matrix-synapse.enable "matrix-synapse.service";
default = optional config.services.matrix-synapse.enable config.services.matrix-synapse.serviceUnit;
defaultText = literalExpression ''
optional config.services.matrix-synapse.enable "matrix-synapse.service"
optional config.services.matrix-synapse.enable config.services.matrix-synapse.serviceUnit
'';
description = lib.mdDoc ''
List of Systemd services to require and wait for when starting the application service.
Expand Down
4 changes: 2 additions & 2 deletions nixos/modules/services/matrix/mautrix-whatsapp.nix
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ in {

serviceDependencies = lib.mkOption {
type = with lib.types; listOf str;
default = lib.optional config.services.matrix-synapse.enable "matrix-synapse.service";
default = lib.optional config.services.matrix-synapse.enable config.services.matrix-synapse.serviceUnit;
defaultText = lib.literalExpression ''
optional config.services.matrix-synapse.enable "matrix-synapse.service"
optional config.services.matrix-synapse.enable config.services.matrix-synapse.serviceUnits
'';
description = lib.mdDoc ''
List of Systemd services to require and wait for when starting the application service.
Expand Down
4 changes: 2 additions & 2 deletions nixos/modules/services/matrix/mx-puppet-discord.nix
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ in {
};
serviceDependencies = mkOption {
type = with types; listOf str;
default = optional config.services.matrix-synapse.enable "matrix-synapse.service";
default = optional config.services.matrix-synapse.enable config.services.matrix-synapse.serviceUnit;
defaultText = literalExpression ''
optional config.services.matrix-synapse.enable "matrix-synapse.service"
optional config.services.matrix-synapse.enable config.services.matrix-synapse.serviceUnit
'';
description = lib.mdDoc ''
List of Systemd services to require and wait for when starting the application service.
Expand Down
13 changes: 13 additions & 0 deletions nixos/modules/services/matrix/synapse.nix
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,18 @@ in {
services.matrix-synapse = {
enable = mkEnableOption (lib.mdDoc "matrix.org synapse");

serviceUnit = lib.mkOption {
type = lib.types.str;
readOnly = true;
description = lib.mdDoc ''
The systemd unit (a service or a target) for other services to depend on if they
need to be started after matrix-synapse.

This option is useful as the actual parent unit for all matrix-synapse processes
changes when configuring workers.
'';
};

configFile = mkOption {
type = types.path;
readOnly = true;
Expand Down Expand Up @@ -1021,6 +1033,7 @@ in {
port = 9093;
});

services.matrix-synapse.serviceUnit = if hasWorkers then "matrix-synapse.target" else "matrix-synapse.service";
services.matrix-synapse.configFile = configFile;
services.matrix-synapse.package = wrapped;

Expand Down