nixos-config/config/host-config/procul.nix

415 lines
12 KiB
Nix
Raw Normal View History

2021-04-14 11:05:55 -07:00
{ config, lib, pkgs, ... }:
2023-05-16 22:40:08 -07:00
with pkgs.lib;
2021-04-14 11:05:55 -07:00
let
hostname = "procul";
2021-11-29 21:18:58 -08:00
2021-04-14 11:05:55 -07:00
host-ipv4 = "172.86.179.18";
2021-07-28 11:55:37 -07:00
git-ipv4 = "172.86.179.19";
domain-name = config.fudo.hosts.${hostname}.domain;
domain = config.fudo.domains.${domain-name};
site-name = config.fudo.hosts.${hostname}.site;
site = config.fudo.sites.${site-name};
host-fqdn = "${hostname}.${domain-name}";
2021-04-14 11:05:55 -07:00
2022-06-01 13:57:58 -07:00
local-networks = domain.local-networks ++ site.local-networks;
2021-04-14 11:05:55 -07:00
local-packages = with pkgs; [ ldns.examples ];
2021-12-18 12:10:42 -08:00
host-secrets = config.fudo.secrets.host-secrets.procul;
passwd = pkgs.lib.fudo.passwd;
2021-11-29 21:34:05 -08:00
host-certs = config.fudo.acme.host-domains.${hostname};
2023-10-14 16:15:26 -07:00
# grafana-database-password = pkgs.lib.passwd.stablerandom-passwd-file
# "grafana-database-password-${hostname}"
# "grafana-database-password-${hostname}-${config.instance.build-seed}";
2022-03-16 09:49:35 -07:00
2021-04-14 11:05:55 -07:00
in {
networking = {
dhcpcd.enable = false;
useDHCP = false;
enableIPv6 = true;
# FIXME: this isn't the right place
search = [ domain-name ];
2021-04-14 11:05:55 -07:00
nameservers = [ "127.0.0.1" ];
defaultGateway = site.gateway-v4;
2021-04-14 11:05:55 -07:00
interfaces = {
extif0 = {
2021-07-28 11:55:37 -07:00
ipv4.addresses = [
{
address = host-ipv4;
prefixLength = 29;
}
{
address = git-ipv4;
prefixLength = 29;
}
];
2021-04-14 11:05:55 -07:00
};
};
};
2023-10-14 16:15:26 -07:00
virtualisation = {
docker.enable = false;
podman = {
enable = true;
autoPrune.enable = true;
dockerSocket.enable = true;
};
oci-containers.backend = "podman";
arion.backend = "podman-socket";
};
services = {
# lemmy = {
# server.package = pkgs.unstable.lemmy-server;
# ui.package = pkgs.unstable.lemmy-ui;
# };
# lemmyDocker = {
# enable = true;
# hostname = "informis.land";
# site-name = "Informis Lemmy";
# version = "0.18.2";
# state-directory = "/state/services/lem";
# smtp-server = "smtp.informis.land:587";
# docker-images = {
# pictrs = "asonix/pictrs:0.4.0-rc.14";
# postgres = "postgres:15-alpine";
# };
# };
nginx = {
enable = true;
recommendedGzipSettings = true;
recommendedOptimisation = true;
recommendedProxySettings = true;
# virtualHosts."lemmy.informis.land" = {
# enableACME = true;
# forceSSL = true;
# locations = {
# "/" = {
# proxyPass =
# "http://localhost:${toString config.services.lemmy.ui.port}";
# proxyWebsockets = true;
# extraConfig = ''
# proxy_set_header Host $host;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection "Upgrade";
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# '';
# };
# "/api" = {
# proxyPass = "http://localhost:${
# toString config.services.lemmy.settings.port
# }";
# proxyWebsockets = true;
# extraConfig = ''
# proxy_set_header Host $host;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection "Upgrade";
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# '';
# };
# };
# };
};
};
2021-04-14 11:05:55 -07:00
environment.systemPackages = local-packages;
networking.firewall.allowedTCPPorts = [ 80 443 ];
2023-10-14 16:15:26 -07:00
security.acme.defaults.email = "root@informis.land";
2022-03-16 09:49:35 -07:00
2021-07-29 22:54:59 -07:00
users = {
2023-05-16 22:40:08 -07:00
users.gituser = {
isSystemUser = true;
group = "nogroup";
2021-04-14 11:05:55 -07:00
};
2023-05-16 22:40:08 -07:00
groups.acme.members = [ "nginx" ];
2021-04-14 11:05:55 -07:00
};
2021-12-18 12:10:42 -08:00
informis = {
cl-gemini = {
enable = true;
2021-04-15 22:15:31 -07:00
2021-12-18 12:10:42 -08:00
hostname = "gemini.informis.land";
server-ip = host-ipv4;
document-root = "/srv/gemini/root";
textfiles-archive = "${pkgs.textfiles}";
slynk-port = 4005;
feeds = {
viator = {
title = "viator's phlog";
path = "/home/viator/gemini-public/feed/";
url = "gemini://informis.land/user/viator/feed/";
};
};
};
2021-04-15 22:15:31 -07:00
2022-03-16 09:49:35 -07:00
# services.chute = let
# secret-files = config.fudo.secrets.files.service-secrets.procul;
# in {
# enable = true;
# jabber-user = "niten@jabber.fudo.org";
# staging = {
# secret-file = secret-files."chute-staging.secret";
# passphrase-file = secret-files."chute-staging.passphrase";
# key-file = secret-files."chute-staging.key";
# };
# };
2021-04-15 22:15:31 -07:00
};
2021-04-14 11:05:55 -07:00
fudo = {
2021-04-15 22:15:31 -07:00
hosts.procul.external-interfaces = [ "extif0" ];
2023-10-14 16:15:26 -07:00
# zones."informis.land".aliases.lemmy = "procul";
2021-11-29 21:34:05 -08:00
acme.host-domains.${hostname} = {
2021-11-29 21:56:28 -08:00
${host-fqdn} = {
admin-email = "admin@${domain-name}";
local-copies = {
postgresql = {
user = config.systemd.services.postgresql.serviceConfig.User;
dependent-services = [ "postgresql.service" ];
part-of = [ config.fudo.postgresql.systemd-target ];
};
2021-11-29 21:34:05 -08:00
};
};
2022-03-16 09:49:35 -07:00
# "imap.${domain-name}" = {
# admin-email = "admin@${domain-name}";
# local-copies.dovecot = {
# user = config.services.dovecot2.user;
# dependent-services = [ "dovecot2.service" ];
# };
# };
# "smtp.${domain-name}" = {
# admin-email = "admin@${domain-name}";
# local-copies.postfix = {
# user = config.services.postfix.user;
# dependent-services = [ "postfix.service" ];
# };
# };
2021-11-29 21:18:58 -08:00
};
2022-06-01 13:57:58 -07:00
secrets.host-secrets.procul = let files = config.fudo.secrets.files;
in {
2022-03-16 09:49:35 -07:00
# postgres-keytab = {
# source-file = files.service-keytabs.procul.postgres;
# target-file = "/srv/postgres/secure/postgres.keytab";
# user = "root";
# };
2021-04-22 11:38:52 -07:00
gitea-database-password = {
source-file = files.service-passwords.procul.gitea-database;
2021-04-22 11:38:52 -07:00
target-file = "/srv/gitea/secure/database.passwd";
user = config.fudo.git.user;
};
2021-11-13 10:30:58 -08:00
2022-03-16 09:49:35 -07:00
postgres-gitea-password = {
source-file = files.service-passwords.procul.gitea-database;
target-file = "/srv/postgres-users/database.passwd";
user = config.services.postgresql.superUser;
};
2023-05-16 22:40:08 -07:00
# heimdal-master-key = {
# source-file = files.realm-master-keys."INFORMIS.LAND";
# target-file = "/run/heimdal/master-key";
# user = config.fudo.auth.kdc.user;
# };
2021-12-18 12:10:42 -08:00
chute-staging-credentials = {
source-file = files.service-secrets.procul."chute-staging.env";
target-file = "/run/chute/staging/credentials.env";
user = "root";
};
2022-03-16 09:49:35 -07:00
2023-10-14 16:15:26 -07:00
# grafana-postgres-password = {
# source-file = grafana-database-password;
# target-file = "/run/metrics/grafana/db.passwd";
# user = config.systemd.services.grafana.serviceConfig.User;
# };
2022-03-16 09:49:35 -07:00
2023-10-14 16:15:26 -07:00
# postgres-grafana-password = {
# source-file = grafana-database-password;
# target-file = "/run/postgres-users/grafana.passwd";
# user = config.services.postgresql.superUser;
# };
};
2021-04-14 11:05:55 -07:00
client.dns = {
ipv4 = true;
ipv6 = true;
user = "fudo-client";
external-interface = "extif0";
};
secure-dns-proxy = {
enable = true;
upstream-dns =
[ "https://1.1.1.1/dns-query" "https://1.0.0.1/dns-query" ];
bootstrap-dns = "1.1.1.1";
listen-ips = [ "127.0.0.1" ];
listen-port = 53;
allowed-networks = [ "1.1.1.1/32" "1.0.0.1/32" "localhost" "link-local" ];
};
2022-03-16 09:49:35 -07:00
# mail-server = {
# enable = true;
# debug = true;
# domain = domain-name;
# mail-hostname = "${host-fqdn}";
# monitoring = false;
# mail-user = "mailuser";
# mail-user-id = 525;
# mail-group = "mailgroup";
# clamav.enable = true;
# dkim.signing = true;
# dovecot = let
# cert-copy =
# host-certs."imap.${domain-name}".local-copies.dovecot;
# in {
# ssl-certificate = cert-copy.full-certificate;
# ssl-private-key = cert-copy.private-key;
# };
# postfix = let
# cert-copy =
# host-certs."smtp.${domain-name}".local-copies.postfix;
# in {
# ssl-certificate = cert-copy.full-certificate;
# ssl-private-key = cert-copy.private-key;
# };
# # This should NOT include the primary domain
# local-domains = [ host-fqdn "smtp.${domain-name}" ];
# mail-directory = "/srv/mailserver/mail";
# state-directory = "/srv/mailserver/state";
# trusted-networks = [ "172.86.179.16/29" "127.0.0.0/16" ];
# alias-users = {
# root = [ "niten" ];
# postmaster = [ "niten" ];
# hostmaster = [ "niten" ];
# webmaster = [ "niten" ];
# system = [ "niten" ];
# admin = [ "niten" ];
# dmarc-report = [ "niten" ];
# };
# };
2021-04-14 11:05:55 -07:00
2022-03-16 09:49:35 -07:00
services = {
auth = {
kerberos = {
state-directory = "/var/lib/kerberos";
master-key-file = host-secrets.heimdal-master-key.target-file;
};
2022-06-01 13:57:58 -07:00
ldap.state-directory = "/state/services/ldap";
2022-03-16 09:49:35 -07:00
};
2023-10-14 16:15:26 -07:00
dns.zones."informis.land".enable = true;
2022-03-16 09:49:35 -07:00
postgresql = {
2023-10-14 16:15:26 -07:00
state-directory = "/state/services/postgresql-15";
2023-05-16 22:40:08 -07:00
keytab = extractFudoHostKeytab {
inherit hostname;
realm = domain.gssapi-realm;
services = [ "postgres" ];
};
2022-03-16 09:49:35 -07:00
};
2023-10-14 16:15:26 -07:00
# lemmy = {
# enable = true;
# hostname = "lemmy.informis.land";
# };
2022-03-16 09:49:35 -07:00
logging.loki.state-directory = "/state/services/loki";
2023-10-14 16:15:26 -07:00
mail-server = { state-directory = "/srv/mailserver"; };
2022-03-16 09:49:35 -07:00
metrics = {
prometheus.state-directory = "/state/services/prometheus";
grafana = {
state-directory = "/state/services/grafana";
2023-10-14 16:15:26 -07:00
# database = {
# user = "grafana";
# password-file = host-secrets.grafana-postgres-password.target-file;
# };
2022-03-16 09:49:35 -07:00
};
2021-04-14 11:05:55 -07:00
};
};
2021-11-29 21:18:58 -08:00
postgresql = let
2022-03-16 09:49:35 -07:00
# cert-copy = host-certs.${host-fqdn}.local-copies.postgresql;
2021-11-29 21:18:58 -08:00
in {
2022-03-16 09:49:35 -07:00
# enable = true;
# ssl-certificate = cert-copy.full-certificate;
# ssl-private-key = cert-copy.private-key;
# keytab = host-secrets.postgres-keytab.target-file;
# local-networks = local-networks;
2021-04-14 11:05:55 -07:00
users = {
2023-10-14 16:15:26 -07:00
# grafana = {
# password-file = host-secrets.postgres-grafana-password.target-file;
# databases.grafana = {
# access = "CONNECT";
# entity-access = {
# "ALL TABLES IN SCHEMA public" = "ALL PRIVILEGES";
# # "SELECT,INSERT,UPDATE,DELETE";
# "ALL SEQUENCES IN SCHEMA public" = "ALL PRIVILEGES";
# # "SELECT, UPDATE";
# };
# };
# };
2022-03-16 09:49:35 -07:00
2021-04-14 11:05:55 -07:00
gituser = {
2022-06-01 13:57:58 -07:00
password-file = host-secrets.postgres-gitea-password.target-file;
2021-04-14 11:05:55 -07:00
databases = {
git = {
access = "CONNECT";
entity-access = {
"ALL TABLES IN SCHEMA public" = "SELECT,INSERT,UPDATE,DELETE";
"ALL SEQUENCES IN SCHEMA public" = "SELECT, UPDATE";
};
};
};
};
};
2022-03-16 09:49:35 -07:00
databases = {
2023-10-14 16:15:26 -07:00
# grafana.users = config.instance.local-admins;
2022-03-16 09:49:35 -07:00
git.users = config.instance.local-admins;
};
2021-04-14 11:05:55 -07:00
};
git = {
enable = true;
hostname = "git.informis.land";
site-name = "informis git";
user = "gituser";
2021-11-13 10:30:58 -08:00
repository-dir = "/srv/git/repo";
state-dir = "/srv/git/state";
2021-04-14 11:05:55 -07:00
database = {
user = "gituser";
2022-06-01 13:57:58 -07:00
password-file = host-secrets.gitea-database-password.target-file;
2021-04-14 11:05:55 -07:00
hostname = "127.0.0.1";
name = "git";
};
ssh = {
listen-ip = host-ipv4;
listen-port = 2222;
};
};
};
}