diff options
author | Janik <80165193+Janik-Haag@users.noreply.github.com> | 2023-12-05 09:29:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-05 09:29:51 +0100 |
commit | 7703f36fd1d5383140cc391df1534d1c46a1b278 (patch) | |
tree | de0f7e240898df60da1527ba90610e69ce73672c /nixos/modules/services/development | |
parent | 4fa7d5f33d2fe3ac294115b021f07242b9985edf (diff) | |
parent | 531fa59187c931c9a5b3b20e49a3dace9d3b5357 (diff) | |
download | nixlib-7703f36fd1d5383140cc391df1534d1c46a1b278.tar nixlib-7703f36fd1d5383140cc391df1534d1c46a1b278.tar.gz nixlib-7703f36fd1d5383140cc391df1534d1c46a1b278.tar.bz2 nixlib-7703f36fd1d5383140cc391df1534d1c46a1b278.tar.lz nixlib-7703f36fd1d5383140cc391df1534d1c46a1b278.tar.xz nixlib-7703f36fd1d5383140cc391df1534d1c46a1b278.tar.zst nixlib-7703f36fd1d5383140cc391df1534d1c46a1b278.zip |
Merge pull request #269469 from NetaliDev/zammad-update
Diffstat (limited to 'nixos/modules/services/development')
-rw-r--r-- | nixos/modules/services/development/zammad.nix | 55 |
1 files changed, 49 insertions, 6 deletions
diff --git a/nixos/modules/services/development/zammad.nix b/nixos/modules/services/development/zammad.nix index 87aceddd6635..c084d6541ad3 100644 --- a/nixos/modules/services/development/zammad.nix +++ b/nixos/modules/services/development/zammad.nix @@ -21,6 +21,7 @@ let NODE_ENV = "production"; RAILS_SERVE_STATIC_FILES = "true"; RAILS_LOG_TO_STDOUT = "true"; + REDIS_URL = "redis://${cfg.redis.host}:${toString cfg.redis.port}"; }; databaseConfig = settingsFormat.generate "database.yml" cfg.database.settings; in @@ -65,6 +66,36 @@ in description = lib.mdDoc "Websocket service port."; }; + redis = { + createLocally = mkOption { + type = types.bool; + default = true; + description = lib.mdDoc "Whether to create a local redis automatically."; + }; + + name = mkOption { + type = types.str; + default = "zammad"; + description = lib.mdDoc '' + Name of the redis server. Only used if `createLocally` is set to true. + ''; + }; + + host = mkOption { + type = types.str; + default = "localhost"; + description = lib.mdDoc '' + Redis server address. + ''; + }; + + port = mkOption { + type = types.port; + default = 6379; + description = lib.mdDoc "Port of the redis server."; + }; + }; + database = { type = mkOption { type = types.enum [ "PostgreSQL" "MySQL" ]; @@ -206,6 +237,10 @@ in assertion = cfg.database.createLocally -> cfg.database.passwordFile == null; message = "a password cannot be specified if services.zammad.database.createLocally is set to true"; } + { + assertion = cfg.redis.createLocally -> cfg.redis.host == "localhost"; + message = "the redis host must be localhost if services.zammad.redis.createLocally is set to true"; + } ]; services.mysql = optionalAttrs (cfg.database.createLocally && cfg.database.type == "MySQL") { @@ -231,6 +266,13 @@ in ]; }; + services.redis = optionalAttrs cfg.redis.createLocally { + servers."${cfg.redis.name}" = { + enable = true; + port = cfg.redis.port; + }; + }; + systemd.services.zammad-web = { inherit environment; serviceConfig = serviceConfig // { @@ -240,6 +282,8 @@ in after = [ "network.target" "postgresql.service" + ] ++ optionals cfg.redis.createLocally [ + "redis-${cfg.redis.name}.service" ]; requires = [ "postgresql.service" @@ -303,16 +347,15 @@ in script = "./script/websocket-server.rb -b ${cfg.host} -p ${toString cfg.websocketPort} start"; }; - systemd.services.zammad-scheduler = { - inherit environment; - serviceConfig = serviceConfig // { Type = "forking"; }; + systemd.services.zammad-worker = { + inherit serviceConfig environment; after = [ "zammad-web.service" ]; requires = [ "zammad-web.service" ]; - description = "Zammad scheduler"; + description = "Zammad background worker"; wantedBy = [ "multi-user.target" ]; - script = "./script/scheduler.rb start"; + script = "./script/background-worker.rb start"; }; }; - meta.maintainers = with lib.maintainers; [ garbas taeer ]; + meta.maintainers = with lib.maintainers; [ taeer netali ]; } |