{ pkgs, lib, ... }:

{
  services.postgresql = {
    enable = true;
    package = lib.mkDefault pkgs.postgresql_18;

    authentication = pkgs.lib.mkOverride 10 ''
      #type database  DBuser  IP address     auth-method
      local all       all                    trust
      host  all       all     127.0.0.1/32   md5
    '';

    ensureDatabases = [
      "giovanni"
    ];

    ensureUsers = [
      {
        name = "giovanni";
        ensureDBOwnership = true;
      }
    ];
  };
}

