2024-03-02 22:05:30 +01:00
|
|
|
{
|
|
|
|
makeSystem,
|
|
|
|
nixpkgs,
|
2023-06-13 23:07:02 +02:00
|
|
|
}:
|
|
|
|
makeSystem {
|
|
|
|
system = "x86_64-linux";
|
|
|
|
name = "nixng-hass-postgresql";
|
|
|
|
inherit nixpkgs;
|
2024-03-02 22:05:30 +01:00
|
|
|
config = {
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
inherit
|
|
|
|
(lib)
|
|
|
|
singleton
|
|
|
|
;
|
|
|
|
in {
|
|
|
|
config = {
|
|
|
|
dumb-init = {
|
|
|
|
enable = true;
|
|
|
|
type.services = {};
|
|
|
|
};
|
|
|
|
services.postgresql = {
|
|
|
|
enable = true;
|
|
|
|
package = pkgs.postgresql_12;
|
2023-06-13 23:07:02 +02:00
|
|
|
|
2024-03-02 22:05:30 +01:00
|
|
|
initialScript = "/secrets/init.sql";
|
|
|
|
enableTCPIP = true;
|
2023-06-13 23:07:02 +02:00
|
|
|
|
2024-03-02 22:05:30 +01:00
|
|
|
authentication = "host all all all md5";
|
2023-06-13 23:07:02 +02:00
|
|
|
|
2024-03-02 22:05:30 +01:00
|
|
|
ensureDatabases = ["hass"];
|
|
|
|
ensureExtensions = {
|
|
|
|
"pg_trgm" = ["hass"];
|
|
|
|
};
|
|
|
|
ensureUsers = singleton {
|
|
|
|
name = "hass";
|
|
|
|
ensurePermissions = {
|
|
|
|
"DATABASE \"hass\"" = "ALL PRIVILEGES";
|
2023-06-13 23:07:02 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-03-02 22:05:30 +01:00
|
|
|
};
|
2023-06-13 23:07:02 +02:00
|
|
|
}
|