mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-02-07 06:19:00 +00:00
hosts/plover: add TLS support for PostgreSQL
This commit is contained in:
parent
4e23ffa6c4
commit
2688064651
@ -2,6 +2,9 @@
|
|||||||
# (thankfully).
|
# (thankfully).
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
postgresqlDomain = "postgres.${config.networking.domain}";
|
||||||
|
in
|
||||||
{
|
{
|
||||||
services.postgresql = {
|
services.postgresql = {
|
||||||
enable = true;
|
enable = true;
|
||||||
@ -30,9 +33,15 @@
|
|||||||
${lib.concatStringsSep "\n" perUserSchemas}
|
${lib.concatStringsSep "\n" perUserSchemas}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
settings = {
|
settings = let
|
||||||
|
credsDir = path: "/run/credentials/postgresql.service/${path}";
|
||||||
|
in {
|
||||||
# Still doing the secure schema usage pattern.
|
# Still doing the secure schema usage pattern.
|
||||||
search_path = "\"$user\"";
|
search_path = "\"$user\"";
|
||||||
|
|
||||||
|
ssl_cert_file = credsDir "cert.pem";
|
||||||
|
ssl_key_file = credsDir "key.pem";
|
||||||
|
ssl_ca_file = credsDir "fullchain.pem";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -45,4 +54,22 @@
|
|||||||
# Start at every 3 days starting from the first day of the month.
|
# Start at every 3 days starting from the first day of the month.
|
||||||
startAt = "*-*-1/3";
|
startAt = "*-*-1/3";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Setting this up for TLS.
|
||||||
|
systemd.services.postgresql = {
|
||||||
|
requires = [ "acme-finished-${postgresqlDomain}.target" ];
|
||||||
|
serviceConfig.LoadCredential = let
|
||||||
|
certDirectory = config.security.acme.certs."${postgresqlDomain}".directory;
|
||||||
|
certCredentialPath = path: "${path}:${certDirectory}/${path}";
|
||||||
|
in
|
||||||
|
[
|
||||||
|
(certCredentialPath "cert.pem")
|
||||||
|
(certCredentialPath "key.pem")
|
||||||
|
(certCredentialPath "fullchain.pem")
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
security.acme.certs."${postgresqlDomain}".reloadServices = [
|
||||||
|
"postgresql.service"
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user