lol

nixos/mobilizon: do not use `ensureDBOwnership`

Mobilizon can have a custom database username and it is not trivial to sort out how to remove this.

In the meantime, for the upcoming 23.11 release, I apply the classical workaround
and defer to Mobilizon's maintainers.

+10 -7
+10 -7
nixos/modules/services/web-apps/mobilizon.nix
··· 212 212 assertion = cfg.nginx.enable -> (cfg.settings.":mobilizon"."Mobilizon.Web.Endpoint".http.ip == settingsFormat.lib.mkTuple [ 0 0 0 0 0 0 0 1 ]); 213 213 message = "Setting the IP mobilizon listens on is only possible when the nginx config is not used, as it is hardcoded there."; 214 214 } 215 - { 216 - assertion = isLocalPostgres -> repoSettings.database == repoSettings.username; 217 - message = '' 218 - When creating a database via NixOS, the db user and db name must be equal! 219 - ''; 220 - } 221 215 ]; 222 216 223 217 services.mobilizon.settings = { ··· 353 347 354 348 # Taken from here: 355 349 # https://framagit.org/framasoft/mobilizon/-/blob/1.1.0/priv/templates/setup_db.eex 350 + # TODO(to maintainers of mobilizon): the owner database alteration is necessary 351 + # as PostgreSQL 15 changed their behaviors w.r.t. to privileges. 352 + # See https://github.com/NixOS/nixpkgs/issues/216989 to get rid 353 + # of that workaround. 356 354 script = 357 355 '' 358 356 psql "${repoSettings.database}" -c "\ 359 357 CREATE EXTENSION IF NOT EXISTS postgis; \ 360 358 CREATE EXTENSION IF NOT EXISTS pg_trgm; \ 361 359 CREATE EXTENSION IF NOT EXISTS unaccent;" 360 + psql -tAc 'ALTER DATABASE "${repoSettings.database}" OWNER TO "${dbUser}";' 361 + 362 362 ''; 363 363 364 364 serviceConfig = { ··· 378 378 ensureUsers = [ 379 379 { 380 380 name = dbUser; 381 - ensureDBOwnership = true; 381 + # Given that `dbUser` is potentially arbitrarily custom, we will perform 382 + # manual fixups in mobilizon-postgres. 383 + # TODO(to maintainers of mobilizon): Feel free to simplify your setup by using `ensureDBOwnership`. 384 + ensureDBOwnership = false; 382 385 } 383 386 ]; 384 387 extraPlugins = with postgresql.pkgs; [ postgis ];