nixfiles/nixos/boxes/colony/vms/shill/containers/colony-psql.nix

90 lines
2.3 KiB
Nix
Raw Normal View History

2022-06-06 17:52:36 +01:00
{ lib, ... }: {
nixos.systems.colony-psql = {
system = "x86_64-linux";
nixpkgs = "mine";
assignments = {
internal = {
name = "colony-psql-ctr";
2022-06-10 23:25:55 +01:00
altNames = [ "colony-psql" ];
2022-06-06 17:52:36 +01:00
domain = lib.my.colony.domain;
ipv4.address = "${lib.my.colony.start.ctrs.v4}4";
ipv6 = {
iid = "::4";
address = "${lib.my.colony.start.ctrs.v6}4";
};
};
};
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 = {
key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICkly/tnPmoX05lDjEpQOkllPqYA0PY92pOKqvx8Po02";
};
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
authentication = with lib.my.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; }
];
};
})
];
};
};
}