nixos/nextcloud: add assertion explaining to set dbtype

Since 25.05 dbtype no longer defaults to sqlite and this yields an error
that is understandable enough but not easy to properly address.

Add an assert that is more explicit.

Before:
```
       error: The option `nodes.nextcloud.services.nextcloud.config.dbtype' was accessed but has no value defined. Try setting the option.
```

After:
```
       error:
       Failed assertions:
       - `services.nextcloud.config.dbtype` must be set explicitly (pgsql, mysql, or sqlite)

       Before 25.05, it used to default to sqlite but that is not recommended by upstream.
       Either set it to sqlite as it used to be, or convert to another type as described
       in the official db conversion page:
       https://docs.nextcloud.com/server/latest/admin_manual/configuration_database/db_conversion.html
```

Link: https://github.com/NixOS/nixpkgs/pull/369242#issuecomment-3036296243
(cherry picked from commit 78a20758e0)
This commit is contained in:
Dominique Martinet
2025-07-04 23:35:51 +09:00
committed by github-actions[bot]
parent bccdc925e1
commit f015b0cc5a

View File

@@ -584,11 +584,14 @@ in
config = {
dbtype = mkOption {
type = types.enum [
"sqlite"
"pgsql"
"mysql"
];
type = types.nullOr (
types.enum [
"sqlite"
"pgsql"
"mysql"
]
);
default = null;
description = "Database type.";
};
dbname = mkOption {
@@ -1093,6 +1096,17 @@ in
instead of password.
'';
}
{
assertion = cfg.config.dbtype != null;
message = ''
`services.nextcloud.config.dbtype` must be set explicitly (pgsql, mysql, or sqlite)
Before 25.05, it used to default to sqlite but that is not recommended by upstream.
Either set it to sqlite as it used to be, or convert to another type as described
in the official db conversion page:
https://docs.nextcloud.com/server/latest/admin_manual/configuration_database/db_conversion.html
'';
}
];
}