dotfiles/nixng/containers/home-assistant/postgresql.nix

43 lines
885 B
Nix
Raw Normal View History

{ makeSystem
, nixpkgs
}:
makeSystem {
system = "x86_64-linux";
name = "nixng-hass-postgresql";
inherit nixpkgs;
config =
{ pkgs, lib, ... }:
let
inherit (lib)
singleton;
in
{
config = {
dumb-init = {
enable = true;
type.services = {};
};
services.postgresql = {
enable = true;
package = pkgs.postgresql_12;
initialScript = "/secrets/init.sql";
enableTCPIP = true;
authentication = "host all all all md5";
ensureDatabases = [ "hass" ];
ensureExtensions = {
"pg_trgm" = [ "hass" ];
};
ensureUsers = singleton {
name = "hass";
ensurePermissions = {
"DATABASE \"hass\"" = "ALL PRIVILEGES";
};
};
};
};
};
}