3838 } ;
3939 authEnabled = mkOption {
4040 type = types . bool ;
41- default = false ;
41+ default = true ;
4242 description = "Enables authentication in SourceBot" ;
4343 } ;
4444 telemetryDisabled = mkOption {
7676 default = 16379 ;
7777 description = "TCP port for the SourceBot Redis server to listen on" ;
7878 } ;
79+ databaseUrl = mkOption {
80+ type = types . nullOr types . str ;
81+ default = "postgresql://sourcebot@localhost:${ toString config . services . postgresql . settings . port } /sourcebot" ;
82+ description = "PostgreSQL connection URL for SourceBot. If not set, a local PostgreSQL server will be configured and used." ;
83+ } ;
7984 } ;
8085
8186 config = mkIf cfg . enable {
155160 Group = "sourcebot" ;
156161 ExecStart = "${ pkgs . prisma } /bin/prisma migrate deploy --schema ${ cfg . package } /packages/db/prisma/schema.prisma" ;
157162 Environment = [
158- "DATABASE_URL=postgresql://sourcebot@localhost:${ toString config . services . postgresql . settings . port } /sourcebot"
159163 "PATH=${ makeBinPath ( with pkgs ; [ prisma openssl ] ) } "
164+ "DATABASE_URL=${ cfg . databaseUrl } "
160165 ] ;
161166 Restart = "on-failure" ;
162167 RestartSec = "5s" ;
@@ -178,15 +183,15 @@ in {
178183 "DATA_CACHE_DIR=${ cfg . dataCacheDir } "
179184 "PORT=${ toString cfg . port } "
180185 "HOSTNAME=${ cfg . hostname } "
181- "DATABASE_URL=postgresql://sourcebot@localhost: ${ toString config . services . postgresql . settings . port } /sourcebot "
186+ "DATABASE_URL=${ cfg . databaseUrl } "
182187 "REDIS_URL=redis://localhost:${ toString cfg . redisPort } "
183188 "CONFIG_PATH=${ cfg . configPath } "
184189 "SOURCEBOT_LOG_LEVEL=${ cfg . logLevel } "
185190 "SOURCEBOT_TENANCY_MODE=single"
186- "SOURCEBOT_AUTH_ENABLED =${ boolToString cfg . authEnabled } "
191+ "AUTH_CREDENTIALS_LOGIN_ENABLED =${ boolToString cfg . authEnabled } "
187192 "SOURCEBOT_TELEMETRY_DISABLED=${ boolToString cfg . telemetryDisabled } "
188193 "SOURCEBOT_PUBLIC_KEY_PATH=${ cfg . package } /public.pem"
189- "AUTH_URL=${ cfg . authUrl } "
194+ "AUTH_URL=http:// ${ cfg . hostname } : ${ toString cfg . port } "
190195 ]
191196 ++ optional ( cfg . envFile == null ) [
192197 "AUTH_SECRET=00000000000000000000000000000000000000000000"
217222 "CONFIG_PATH=${ cfg . configPath } "
218223 "SOURCEBOT_LOG_LEVEL=${ cfg . logLevel } "
219224 "SOURCEBOT_TENANCY_MODE=single"
220- "SOURCEBOT_AUTH_ENABLED =${ boolToString cfg . authEnabled } "
225+ "AUTH_CREDENTIALS_LOGIN_ENABLED =${ boolToString cfg . authEnabled } "
221226 "SOURCEBOT_TELEMETRY_DISABLED=${ boolToString cfg . telemetryDisabled } "
222227 "SOURCEBOT_PUBLIC_KEY_PATH=${ cfg . package } /public.pem"
223228 "AUTH_URL=http://${ cfg . hostname } :${ toString cfg . port } "
0 commit comments