# Development services module - Matrix, Forgejo, and Slack bridge { config, pkgs, pkgs-unstable, lib, ... }: with lib; let cfg = config.services.dev-platform; in { options.services.dev-platform = { enable = mkEnableOption "development platform with Matrix and Forgejo"; domain = mkOption { type = types.str; default = "localhost"; description = "Base domain for services"; }; matrix = { enable = mkOption { type = types.bool; default = true; description = "Enable Matrix server"; }; serverName = mkOption { type = types.str; default = cfg.domain; description = "Matrix server name"; }; port = mkOption { type = types.port; default = 8008; description = "Matrix server port"; }; }; forgejo = { enable = mkOption { type = types.bool; default = true; description = "Enable Forgejo git service"; }; subdomain = mkOption { type = types.str; default = "git"; description = "Subdomain for Forgejo"; }; port = mkOption { type = types.port; default = 3000; description = "Forgejo port"; }; }; slackBridge = { enable = mkOption { type = types.bool; default = false; description = "Enable Slack bridge"; }; workspace = mkOption { type = types.str; default = ""; description = "Slack workspace name"; }; port = mkOption { type = types.port; default = 29319; description = "Slack bridge port"; }; }; }; config = mkIf cfg.enable { # PostgreSQL for Forgejo and bridge services (Matrix uses RocksDB) services.postgresql = { enable = true; ensureDatabases = [ "forgejo" ] ++ optional cfg.slackBridge.enable "mautrix_slack"; ensureUsers = [ { name = "forgejo"; ensureDBOwnership = true; } ] ++ optional cfg.slackBridge.enable { name = "mautrix_slack"; ensureDBOwnership = true; }; }; # Matrix Continuwuity server systemd.services.matrix-continuwuity = mkIf cfg.matrix.enable { description = "Continuwuity Matrix homeserver"; after = [ "network.target" ]; wants = [ "network-online.target" ]; wantedBy = [ "multi-user.target" ]; preStart = '' # Generate config file at runtime with secret injection from systemd credentials cat > /var/lib/matrix-continuwuity/continuwuity.toml <