193 lines
6.1 KiB
Nix
Raw Normal View History

2023-11-13 10:59:41 -08:00
{ config, lib, pkgs, ... }@toplevel:
2021-02-25 20:45:50 +00:00
2023-10-14 16:15:26 -07:00
with lib;
let
hostname = config.instance.hostname;
localDomain = "fudo.org";
domainSecrets = config.fudo.secrets.files.domain-secrets."${localDomain}";
2023-10-14 16:15:26 -07:00
2023-12-04 17:10:57 -08:00
inherit (pkgs.lib) getDomainHosts getHostIpv4 getHostIpv6 getHostFqdn;
2023-11-13 10:59:41 -08:00
2023-10-14 16:15:26 -07:00
domain = config.fudo.domains."${localDomain}";
authentikHost = "legatus";
primaryNameserver = "germany";
2023-11-13 10:59:41 -08:00
defaultHost = "germany";
mastodonHostname = "fudo.live";
lemmyHost = "germany";
lemmyHostname = "fudo.social";
2023-11-13 10:59:41 -08:00
2023-12-04 17:10:57 -08:00
servedDomains = [
"fudo.org"
"test.fudo.org"
"selby.ca"
"fudo.ca"
"fudo.im"
"fudo.live"
"fudo.social"
2023-12-04 17:10:57 -08:00
"stewartsoundservices.ca"
];
2023-10-14 16:15:26 -07:00
in {
imports = [
(import ./fudo.org/authentik.nix {
inherit authentikHost;
authentikImage = "ghcr.io/goauthentik/server:2023.10.6";
})
2023-10-14 16:15:26 -07:00
(import ./fudo.org/mastodon.nix {
mastodonHost = "germany";
2023-11-13 10:59:41 -08:00
mastodonHostname = mastodonHostname;
mastodonWebDomain = mastodonHostname;
mastodonOidcClientId = domainSecrets."mastodon-oidc.clientid";
mastodonOidcClientSecret = domainSecrets."mastodon-oidc.secret";
2023-10-14 16:15:26 -07:00
})
(import ./fudo.org/nextcloud.nix {
nextcloudHost = "legatus";
nextcloudHostname = "cloud.fudo.org";
nextcloudPackage = pkgs.nextcloud28;
2023-10-14 16:15:26 -07:00
})
(import ./fudo.org/matrix.nix {
matrixHost = "germany";
matrixServerName = "fudo.im";
openIdClientId = readFile domainSecrets."matrix-oidc.clientid";
openIdClientSecret = readFile domainSecrets."matrix-oidc.secret";
2023-10-14 16:15:26 -07:00
})
(import ./fudo.org/mail-server.nix (rec {
primaryMailserver = "france";
primaryDomain = "fudo.org";
2023-10-14 16:15:26 -07:00
authentikServer = "authentik.fudo.org";
ldapBase = "dc=fudo,dc=org";
ldapBindDn = "cn=userdb,ou=users,${ldapBase}";
ldapBindPwFile = domainSecrets."ldap-bind.passwd";
2023-10-14 16:15:26 -07:00
saslDomain = "FUDO.ORG";
authentikOutpostToken = domainSecrets."authentik-ldap.token";
2023-12-04 17:10:57 -08:00
inherit servedDomains;
dkimRecord = ''
mail._domainkey IN TXT ( "v=DKIM1;k=rsa;p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCwoCgHwsfuu0lhj9Ayj4ntoy0bdcGBNsV46qoKbd8E8FKsJF5rL4EoytwXEFcKJwT3E+o3/BsZGi9J5irtjlfIhnxnPlhVRS3R/834NDSQyuwGTxAfhPOklhA0cTYA+4x2oGwAuraz+On2REDeSymMccXFDsTugEHVvn6qaeqkJwIDAQAB" );'';
2023-10-14 16:15:26 -07:00
}))
];
2023-12-04 17:10:57 -08:00
2023-10-14 16:15:26 -07:00
config = {
# All Fudo hosts should redirect selby.ca to the selbyhomecentre website.
services = {
nginx.virtualHosts = {
# Pass requests to selby on to selbyhomecentre
"selby.ca".locations."/".return =
"301 https://selbyhomecentre.com$request_uri";
"www.selby.ca".locations."/".return =
"301 https://selbyhomecentre.com$request_uri";
# For Mastodon
"fudo.org".locations = {
"/.well-known/webfinger" = {
return = "301 http://${mastodonHostname}";
extraConfig = "add_header Access-Control-Allow-Origin '*';";
};
"/.well-known/host-meta" = {
return = "301 https://${mastodonHostname}$request_uri";
};
2023-11-13 10:59:41 -08:00
};
};
lemmyDocker = {
enable = config.instance.hostname == lemmyHost;
hostname = lemmyHostname;
site-name = "Fudo Lemmy";
version = "0.19.2";
smtp-server = "mail.fudo.org:587";
docker-images = {
pictrs = "asonix/pictrs:0.5.1";
postgres = "postgres:15-alpine";
2023-11-13 10:59:41 -08:00
};
};
2023-10-14 16:15:26 -07:00
};
2023-12-04 17:10:57 -08:00
fudo = {
services = {
# TEMPORARY
mail-server.enable = false;
2023-12-04 17:10:57 -08:00
jabber = {
domain = "jabber.fudo.org";
ldap.servers =
map (host: "${host}.${localDomain}") domain.ldap-servers;
2023-11-13 10:59:41 -08:00
};
metrics.grafana = {
oauth = {
hostname = "authentik.fudo.org";
client-id = domainSecrets."grafana-oid-client-id";
client-secret = domainSecrets."grafana-oid-client-secret";
slug = "grafana-metrics";
};
};
2023-12-04 17:10:57 -08:00
authoritative-dns = {
enable = hostname == primaryNameserver;
enable-notifications = true;
2023-12-04 17:10:57 -08:00
container = {
hostname = "nameserver";
interface = "enp5s0f0";
2023-11-13 10:59:41 -08:00
};
2023-12-04 17:10:57 -08:00
nameservers = {
primary = "nameserver";
2023-12-04 17:10:57 -08:00
external = map (hostname: {
inherit (config.fudo.zones."fudo.org".hosts."${hostname}")
ipv4-address ipv6-address description;
}) [ "ns2-fudo" "ns3-fudo" "ns4-fudo" ];
2023-10-14 16:15:26 -07:00
};
2023-12-04 17:10:57 -08:00
ip-host-map = let
networkHosts = getDomainHosts "fudo.org";
ipHostPairs =
map (host: nameValuePair (getHostIpv4 host) (getHostFqdn host))
networkHosts;
in listToAttrs ipHostPairs;
zones = let
defaultDeets = {
inherit (config.fudo.zones."fudo.org".hosts."${defaultHost}")
ipv4-address ipv6-address sshfp-records;
description = "fudo.org";
};
# TODO: Fix email FFS!
2023-12-04 17:10:57 -08:00
fudoMailservers = {
smtp-servers = [ "mail.fudo.org." ];
imap-servers = [ "mail.fudo.org." ];
2023-12-04 17:10:57 -08:00
};
mkDomain = domain: extraConfig:
{
default-host = defaultDeets;
ksk =
config.fudo.secrets.files.dns.key-signing-keys."${domain}";
} // extraConfig;
in {
"fudo.org" = mkDomain "fudo.org" {
reverse-zones = [ "208.81.1.128/28" "208.81.3.112/28" ];
mail = fudoMailservers;
};
"test.fudo.org" = mkDomain "test.fudo.org" { };
"selby.ca" = mkDomain "selby.ca" { mail = fudoMailservers; };
"fudo.ca" = mkDomain "fudo.ca" { mail = fudoMailservers; };
"fudo.im" = mkDomain "fudo.im" { mail = fudoMailservers; };
"stewartsoundservices.ca" =
mkDomain "stewartsoundservices.ca" { mail = fudoMailservers; };
"fudo.live" = mkDomain "fudo.live" { mail = fudoMailservers; };
"fudo.social" = mkDomain "fudo.social" { mail = fudoMailservers; };
2023-10-14 16:15:26 -07:00
};
};
};
};
};
2022-03-16 09:49:35 -07:00
}