2023-05-27 16:57:28 +01:00
|
|
|
{ lib, ... }:
|
|
|
|
let
|
|
|
|
inherit (lib.my) net;
|
2023-11-02 13:41:50 +00:00
|
|
|
inherit (lib.my.c.colony) domain prefixes;
|
2023-05-27 16:57:28 +01:00
|
|
|
in
|
|
|
|
{
|
2023-11-16 21:42:30 +00:00
|
|
|
nixos.systems.colony-psql = { config, ... }: {
|
2022-06-06 17:52:36 +01:00
|
|
|
system = "x86_64-linux";
|
|
|
|
nixpkgs = "mine";
|
2023-11-16 21:42:30 +00:00
|
|
|
rendered = config.configuration.config.my.asContainer;
|
2022-06-06 17:52:36 +01:00
|
|
|
|
|
|
|
assignments = {
|
|
|
|
internal = {
|
|
|
|
name = "colony-psql-ctr";
|
2022-06-10 23:25:55 +01:00
|
|
|
altNames = [ "colony-psql" ];
|
2023-05-27 16:57:28 +01:00
|
|
|
inherit domain;
|
|
|
|
ipv4.address = net.cidr.host 4 prefixes.ctrs.v4;
|
2022-06-06 17:52:36 +01:00
|
|
|
ipv6 = {
|
|
|
|
iid = "::4";
|
2023-05-27 16:57:28 +01:00
|
|
|
address = net.cidr.host 4 prefixes.ctrs.v6;
|
2022-06-06 17:52:36 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
configuration = { lib, pkgs, config, assignments, ... }:
|
|
|
|
let
|
|
|
|
inherit (lib) mkMerge mkIf;
|
|
|
|
inherit (lib.my) networkdAssignment;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
config = mkMerge [
|
|
|
|
{
|
|
|
|
my = {
|
|
|
|
deploy.enable = false;
|
|
|
|
server.enable = true;
|
|
|
|
|
|
|
|
secrets = {
|
2022-06-19 17:55:09 +01:00
|
|
|
key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINjxrgtTqLfKzmg14ZajkgViNXaM4cuTMvuJqETvj4Iv";
|
2022-06-06 17:52:36 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
firewall = {
|
2022-06-13 02:14:18 +01:00
|
|
|
tcp.allowed = [ 19999 5432 ];
|
2022-06-06 17:52:36 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd = {
|
|
|
|
network.networks."80-container-host0" = networkdAssignment "host0" assignments.internal;
|
|
|
|
};
|
|
|
|
|
|
|
|
services = {
|
2022-06-13 02:14:18 +01:00
|
|
|
netdata = {
|
|
|
|
enable = true;
|
|
|
|
python = {
|
|
|
|
enable = true;
|
|
|
|
extraPackages = ps: with ps; [ psycopg2 ];
|
|
|
|
};
|
|
|
|
configDir = {
|
|
|
|
"python.d/postgres.conf" = pkgs.writeText "netdata-postgres.conf" ''
|
|
|
|
local:
|
|
|
|
user: postgres
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-06-06 17:52:36 +01:00
|
|
|
postgresql = {
|
|
|
|
package = pkgs.postgresql_14;
|
|
|
|
enable = true;
|
|
|
|
enableTCPIP = true;
|
2022-06-10 23:25:55 +01:00
|
|
|
|
2023-11-02 13:41:50 +00:00
|
|
|
authentication = with lib.my.c.colony.prefixes; ''
|
2022-06-13 02:14:18 +01:00
|
|
|
local all postgres peer map=local
|
|
|
|
|
2022-06-10 23:25:55 +01:00
|
|
|
host all all ${all.v4} md5
|
|
|
|
host all all ${all.v6} md5
|
|
|
|
'';
|
2022-06-13 02:14:18 +01:00
|
|
|
identMap = ''
|
|
|
|
local postgres postgres
|
|
|
|
local root postgres
|
|
|
|
local netdata postgres
|
|
|
|
local dev postgres
|
|
|
|
'';
|
2022-06-06 17:52:36 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
(mkIf config.my.build.isDevVM {
|
|
|
|
virtualisation = {
|
|
|
|
forwardPorts = [
|
|
|
|
{ from = "host"; host.port = 55432; guest.port = 5432; }
|
|
|
|
];
|
|
|
|
};
|
|
|
|
})
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|