nixos-config/hosts/plover/default.nix

119 lines
3.1 KiB
Nix
Raw Normal View History

{ config, lib, pkgs, modulesPath, ... }:
2022-11-23 05:27:01 +00:00
let
inherit (import ./modules/hardware/networks.nix) interfaces;
2022-11-23 05:27:01 +00:00
in
{
imports = [
# 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
# The users for this host.
(lib.getUser "nixos" "admin")
2022-11-26 06:13:17 +00:00
(lib.getUser "nixos" "plover")
# Hardened profile from nixpkgs.
"${modulesPath}/profiles/hardened.nix"
2023-01-12 13:22:55 +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
# The primary DNS server that is completely hidden.
./modules/services/bind.nix
# 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.
./modules/services/prometheus.nix
2023-10-07 19:27:47 +00:00
./modules/services/grafana.nix
# 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
./modules/services/wireguard.nix
./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" ];
};
networking = {
2023-01-06 12:26:57 +00:00
nftables.enable = true;
domain = "foodogsquared.one";
firewall = {
2023-02-06 08:09:09 +00:00
enable = true;
allowedTCPPorts = [
22 # Secure Shells.
];
};
};
2023-02-09 06:17:59 +00:00
services.fail2ban = {
ignoreIP = [
# VPN clients.
"${interfaces.wireguard0.IPv4.address}/13"
"${interfaces.wireguard0.IPv6.address}/64"
];
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.
jails.sshd.settings = {
enabled = true;
maxretry = 1;
};
2023-02-09 06:17:59 +00:00
};
2023-07-05 03:38:58 +00:00
sops.secrets = lib.getSecrets ./secrets/secrets.yaml {
"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
# self-hosted DNS server.
security.acme.defaults = {
email = "admin+acme@foodogsquared.one";
dnsProvider = "rfc2136";
dnsResolver = "1.1.1.1";
credentialsFile = config.sops.secrets."lego/env".path;
2022-12-03 00:09:26 +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 = [{
path = config.sops.secrets."ssh-key".path;
2022-12-02 04:33:51 +00:00
type = "ed25519";
}];
system.stateVersion = "23.11";
2022-11-23 05:27:01 +00:00
}