nixos/discourse: Assert deployed PostgreSQL version
Assert that the PostgreSQL version being deployed is the one used upstream. Allow the user to override this assertion, since it's not always possible or preferable to use the recommended one.master
parent
2dec0de3c0
commit
cb80b67993
|
@ -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 = "Could not automatically determine hostname, set service.discourse.hostname manually.";
|
||||
}
|
||||
{
|
||||
assertion = cfg.database.ignorePostgresqlVersion || (databaseActuallyCreateLocally -> upstreamPostgresqlVersion == postgresqlVersion);
|
||||
message = "The PostgreSQL version recommended for use with Discourse is ${upstreamPostgresqlVersion}, you're using ${postgresqlVersion}. "
|
||||
+ "Either update your PostgreSQL package to the correct version or set services.discourse.database.ignorePostgresqlVersion. "
|
||||
+ "See https://nixos.org/manual/nixos/stable/index.html#module-postgresql for details on how to upgrade PostgreSQL.";
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
|
|
|
@ -51,6 +51,8 @@ import ./make-test-python.nix (
|
|||
|
||||
environment.systemPackages = [ pkgs.jq ];
|
||||
|
||||
services.postgresql.package = pkgs.postgresql_13;
|
||||
|
||||
services.discourse = {
|
||||
enable = true;
|
||||
inherit admin;
|
||||
|
|
Loading…
Reference in New Issue