2023-10-02 06:26:11 +00:00
|
|
|
{ config, lib, pkgs, modulesPath, ... }:
|
2022-11-23 05:27:01 +00:00
|
|
|
|
|
|
|
let
|
2023-01-25 03:38:45 +00:00
|
|
|
inherit (import ./modules/hardware/networks.nix) interfaces;
|
2022-11-23 05:27:01 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
imports = [
|
2023-01-14 07:55:30 +00:00
|
|
|
# Since this will be rarely configured, make sure to import the appropriate
|
|
|
|
# hardware modules depending on the hosting provider (and even just the
|
|
|
|
# server).
|
|
|
|
./modules/hardware/hetzner-cloud-cx21.nix
|
2022-11-26 06:13:17 +00:00
|
|
|
|
2022-12-03 05:46:46 +00:00
|
|
|
# The users for this host.
|
|
|
|
(lib.getUser "nixos" "admin")
|
2022-11-26 06:13:17 +00:00
|
|
|
(lib.getUser "nixos" "plover")
|
2022-12-03 03:11:48 +00:00
|
|
|
|
2022-12-03 07:46:22 +00:00
|
|
|
# Hardened profile from nixpkgs.
|
2022-12-03 03:11:48 +00:00
|
|
|
"${modulesPath}/profiles/hardened.nix"
|
2023-01-12 13:22:55 +00:00
|
|
|
|
2023-11-06 08:59:20 +00:00
|
|
|
# Of course, what is a server without a backup? A professionally-handled
|
|
|
|
# production system. However, we're not professionals so we do have
|
|
|
|
# backups.
|
|
|
|
./modules/services/borgbackup.nix
|
|
|
|
|
2023-02-08 10:00:35 +00:00
|
|
|
# The primary DNS server that is completely hidden.
|
2023-06-22 09:56:47 +00:00
|
|
|
./modules/services/bind.nix
|
2023-02-08 10:00:35 +00:00
|
|
|
|
2023-02-08 10:03:20 +00:00
|
|
|
# The reverse proxy of choice.
|
2023-01-12 13:22:55 +00:00
|
|
|
./modules/services/nginx.nix
|
|
|
|
|
2023-10-07 19:28:14 +00:00
|
|
|
# The single-sign on setup.
|
|
|
|
./modules/services/kanidm.nix
|
|
|
|
./modules/services/vouch-proxy.nix
|
|
|
|
|
2023-10-07 19:27:47 +00:00
|
|
|
# The monitoring stack.
|
2023-10-07 19:28:35 +00:00
|
|
|
./modules/services/prometheus.nix
|
2023-10-07 19:27:47 +00:00
|
|
|
./modules/services/grafana.nix
|
|
|
|
|
2023-01-13 07:26:32 +00:00
|
|
|
# The database of choice which is used by most self-managed services on
|
|
|
|
# this server.
|
|
|
|
./modules/services/postgresql.nix
|
|
|
|
|
2023-01-12 13:22:55 +00:00
|
|
|
# The application services for this server. They are modularized since
|
|
|
|
# configuring it here will make it too big.
|
|
|
|
./modules/services/atuin.nix
|
|
|
|
./modules/services/gitea.nix
|
|
|
|
./modules/services/vaultwarden.nix
|
2023-01-17 08:05:11 +00:00
|
|
|
./modules/services/wireguard.nix
|
2023-07-20 02:40:45 +00:00
|
|
|
./modules/services/wezterm-mux-server.nix
|
2022-11-23 05:27:01 +00:00
|
|
|
];
|
|
|
|
|
2023-06-30 05:38:38 +00:00
|
|
|
# Automatic format and partitioning.
|
|
|
|
disko.devices = import ./disko.nix {
|
|
|
|
disks = [ "/dev/sda" ];
|
|
|
|
};
|
|
|
|
|
2022-12-10 10:45:36 +00:00
|
|
|
networking = {
|
2023-01-06 12:26:57 +00:00
|
|
|
nftables.enable = true;
|
2022-12-10 10:45:36 +00:00
|
|
|
domain = "foodogsquared.one";
|
2023-01-05 11:48:54 +00:00
|
|
|
firewall = {
|
2023-02-06 08:09:09 +00:00
|
|
|
enable = true;
|
2023-01-05 11:48:54 +00:00
|
|
|
allowedTCPPorts = [
|
|
|
|
22 # Secure Shells.
|
|
|
|
];
|
|
|
|
};
|
2022-12-10 10:45:36 +00:00
|
|
|
};
|
2022-11-27 16:41:44 +00:00
|
|
|
|
2023-02-09 06:17:59 +00:00
|
|
|
services.fail2ban = {
|
|
|
|
ignoreIP = [
|
|
|
|
# VPN clients.
|
|
|
|
"${interfaces.wireguard0.IPv4.address}/13"
|
|
|
|
"${interfaces.wireguard0.IPv6.address}/64"
|
|
|
|
];
|
2023-01-25 03:38:45 +00:00
|
|
|
|
2023-02-09 06:17:59 +00:00
|
|
|
# We're going to be unforgiving with this one since we only have key
|
|
|
|
# authentication and password authentication is disabled anyways.
|
2023-07-14 06:41:58 +00:00
|
|
|
jails.sshd.settings = {
|
|
|
|
enabled = true;
|
|
|
|
maxretry = 1;
|
|
|
|
};
|
2023-02-09 06:17:59 +00:00
|
|
|
};
|
2023-01-17 08:05:11 +00:00
|
|
|
|
2023-11-06 08:59:20 +00:00
|
|
|
|
2023-07-05 03:38:58 +00:00
|
|
|
sops.secrets = lib.getSecrets ./secrets/secrets.yaml {
|
2023-07-05 05:11:47 +00:00
|
|
|
"ssh-key" = { };
|
|
|
|
"lego/env" = { };
|
2023-07-05 03:38:58 +00:00
|
|
|
};
|
2022-11-23 05:27:01 +00:00
|
|
|
|
2023-01-12 13:22:55 +00:00
|
|
|
# All of the keys required to deploy the secrets.
|
2022-11-23 05:27:01 +00:00
|
|
|
sops.age.keyFile = "/var/lib/sops-nix/key.txt";
|
|
|
|
|
2022-12-02 04:33:51 +00:00
|
|
|
profiles.server = {
|
|
|
|
enable = true;
|
|
|
|
headless.enable = true;
|
|
|
|
hardened-config.enable = true;
|
|
|
|
cleanup.enable = true;
|
|
|
|
};
|
|
|
|
|
2023-01-12 13:22:55 +00:00
|
|
|
# DNS-related settings. We're settling by configuring the ACME setup with a
|
2023-06-22 09:56:47 +00:00
|
|
|
# self-hosted DNS server.
|
2022-12-29 02:26:15 +00:00
|
|
|
security.acme.defaults = {
|
2023-06-27 14:56:18 +00:00
|
|
|
email = "admin+acme@foodogsquared.one";
|
2023-06-22 09:56:47 +00:00
|
|
|
dnsProvider = "rfc2136";
|
2023-06-27 14:56:18 +00:00
|
|
|
dnsResolver = "1.1.1.1";
|
2023-07-05 05:11:47 +00:00
|
|
|
credentialsFile = config.sops.secrets."lego/env".path;
|
2022-12-03 00:09:26 +00:00
|
|
|
};
|
|
|
|
|
2023-06-30 02:46:43 +00:00
|
|
|
# Enable generating new DH params.
|
|
|
|
security.dhparams.enable = true;
|
|
|
|
|
|
|
|
# !!! The keys should be rotated at an interval here.
|
2022-12-02 04:33:51 +00:00
|
|
|
services.openssh.hostKeys = [{
|
2023-07-05 05:11:47 +00:00
|
|
|
path = config.sops.secrets."ssh-key".path;
|
2022-12-02 04:33:51 +00:00
|
|
|
type = "ed25519";
|
|
|
|
}];
|
|
|
|
|
2023-08-03 05:29:00 +00:00
|
|
|
system.stateVersion = "23.11";
|
2022-11-23 05:27:01 +00:00
|
|
|
}
|