diff options
author | talyz <kim.lindberger@gmail.com> | 2021-05-27 11:41:35 +0200 |
---|---|---|
committer | Jonathan Ringer <jonringer@users.noreply.github.com> | 2021-05-28 17:43:02 -0700 |
commit | cb80b67993d6ba195c3329606aab5fb981d8323c (patch) | |
tree | f56352ea37a83c66c2ce77bc286b81ae1c11e8ea | |
parent | 2dec0de3c039406950aaa79cbdeb9bfbcae4f87d (diff) | |
download | nixpkgs-cb80b67993d6ba195c3329606aab5fb981d8323c.tar nixpkgs-cb80b67993d6ba195c3329606aab5fb981d8323c.tar.gz nixpkgs-cb80b67993d6ba195c3329606aab5fb981d8323c.tar.bz2 nixpkgs-cb80b67993d6ba195c3329606aab5fb981d8323c.tar.lz nixpkgs-cb80b67993d6ba195c3329606aab5fb981d8323c.tar.xz nixpkgs-cb80b67993d6ba195c3329606aab5fb981d8323c.tar.zst nixpkgs-cb80b67993d6ba195c3329606aab5fb981d8323c.zip |
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.
-rw-r--r-- | nixos/modules/services/web-apps/discourse.nix | 22 | ||||
-rw-r--r-- | nixos/tests/discourse.nix | 2 |
2 files changed, 24 insertions, 0 deletions
diff --git a/nixos/modules/services/web-apps/discourse.nix b/nixos/modules/services/web-apps/discourse.nix index ba5989800ea..49958fc6190 100644 --- a/nixos/modules/services/web-apps/discourse.nix +++ b/nixos/modules/services/web-apps/discourse.nix @@ -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."; + } ]; diff --git a/nixos/tests/discourse.nix b/nixos/tests/discourse.nix index 3c965550fe0..2ed6fb957c2 100644 --- a/nixos/tests/discourse.nix +++ b/nixos/tests/discourse.nix @@ -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; |