Postgres syntax error when trying to grant permissions with Nix

I’m trying to create Postgres user and database declaratively. I need user pleroma to have all permissions on database pleroma, that’s why I created this config:

services = {
    postgresql = {
      enable = true;
      package = pkgs.postgresql_12;
      ensureDatabases = [ "pleroma" ];
      ensureUsers = [
        { name = "pleroma";
          ensurePermissions."DATABASE pleroma" = "ALL PERMISSIONS";
        }
      ];
    };
  };

But, when I apply this config, Postgresql service fails to start due to syntax error:
journalctl -xe

Oct 29 16:03:54 ilchub postgres[16145]: [16145] LOG:  starting PostgreSQL 12.4 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 9.3.0, 64-bit
Oct 29 16:03:54 ilchub postgres[16145]: [16145] LOG:  listening on IPv6 address "::1", port 5432
Oct 29 16:03:54 ilchub postgres[16145]: [16145] LOG:  listening on IPv4 address "127.0.0.1", port 5432
Oct 29 16:03:54 ilchub postgres[16145]: [16145] LOG:  listening on Unix socket "/run/postgresql/.s.PGSQL.5432"
Oct 29 16:03:54 ilchub postgres[16146]: [16146] LOG:  database system was shut down at 2020-10-29 15:56:12 GMT
Oct 29 16:03:54 ilchub postgres[16145]: [16145] LOG:  database system is ready to accept connections
Oct 29 16:03:54 ilchub postgres[16163]: [16163] ERROR:  syntax error at or near "PERMISSIONS" at character 11
Oct 29 16:03:54 ilchub postgres[16163]: [16163] STATEMENT:  GRANT ALL PERMISSIONS ON DATABASE pleroma TO "pleroma"
Oct 29 16:03:54 ilchub postgresql-post-start[16162]: ERROR:  syntax error at or near "PERMISSIONS"
Oct 29 16:03:54 ilchub postgresql-post-start[16162]: LINE 1: GRANT ALL PERMISSIONS ON DATABASE pleroma TO "pleroma"
Oct 29 16:03:54 ilchub postgresql-post-start[16162]:                   ^
Oct 29 16:03:54 ilchub systemd[1]: postgresql.service: Control process exited, code=exited, status=1/FAILURE

What am I doing wrong and how to omit this error?

According to the postgresql documentation the command should be GRANT ALL PRIVILEGES ON ... (PRIVILEGES is also optional).
So if you replace PERMISSIONS with PRIVILEGES (or just leave it out) it should work.

(Note I haven’t used these options in nix yet, this is based only on the executed command from the logs)