@ -5,11 +5,16 @@ let
cfg = config . services . discourse ;
# Keep in sync with https://github.com/discourse/discourse_docker/blob/master/image/base/Dockerfile#L5
upstreamPostgresqlVersion = lib . getVersion pkgs . postgresql_13 ;
postgresqlPackage = if config . services . postgresql . enable then
config . services . postgresql . package
else
pkgs . postgresql ;
postgresqlVersion = lib . getVersion postgresqlPackage ;
# We only want to create a database if we're actually going to connect to it.
databaseActuallyCreateLocally = cfg . database . createLocally && cfg . database . host == null ;
@ -263,6 +268,17 @@ in
Discourse database user .
'' ;
} ;
ignorePostgresqlVersion = lib . mkOption {
type = lib . types . bool ;
default = false ;
description = ''
Whether to allow other versions of PostgreSQL than the
recommended one . Only effective when
<option> services . discourse . database . createLocally < /option >
is enabled .
'' ;
} ;
} ;
redis = {
@ -505,6 +521,12 @@ in
assertion = cfg . hostname != " " ;
message = " C o u l d n o t a u t o m a t i c a l l y d e t e r m i n e h o s t n a m e , s e t s e r v i c e . d i s c o u r s e . h o s t n a m e m a n u a l l y . " ;
}
{
assertion = cfg . database . ignorePostgresqlVersion || ( databaseActuallyCreateLocally -> upstreamPostgresqlVersion == postgresqlVersion ) ;
message = " T h e P o s t g r e S Q L v e r s i o n r e c o m m e n d e d f o r u s e w i t h D i s c o u r s e i s ${ upstreamPostgresqlVersion } , y o u ' r e u s i n g ${ postgresqlVersion } . "
+ " E i t h e r u p d a t e y o u r P o s t g r e S Q L p a c k a g e t o t h e c o r r e c t v e r s i o n o r s e t s e r v i c e s . d i s c o u r s e . d a t a b a s e . i g n o r e P o s t g r e s q l V e r s i o n . "
+ " S e e h t t p s : / / n i x o s . o r g / m a n u a l / n i x o s / s t a b l e / i n d e x . h t m l # m o d u l e - p o s t g r e s q l f o r d e t a i l s o n h o w t o u p g r a d e P o s t g r e S Q L . " ;
}
] ;