Skip to content

Instantly share code, notes, and snippets.

@drupol
Created December 6, 2022 09:14
Show Gist options
  • Save drupol/920192c718f44031a23f95a437c0598c to your computer and use it in GitHub Desktop.
Save drupol/920192c718f44031a23f95a437c0598c to your computer and use it in GitHub Desktop.
{ modulesPath, pkgs, lib, config, ... }:
let
db_name = "<name>";
db_user = "<user>";
in
{
services.postgresql =
{
enable = true;
package = pkgs.postgresql_13;
ensureDatabases = [ db_name ];
authentication = pkgs.lib.mkOverride 10 ''
local all all trust
host all all 127.0.0.1/32 trust
host all all ::1/128 trust
'';
ensureUsers = [
{
name = db_user;
ensurePermissions = { "DATABASE ${db_name}" = "ALL PRIVILEGES"; };
}
];
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment