2023-10-02 06:26:11 +00:00
|
|
|
{ config, lib, pkgs, modulesPath, ... }:
|
2022-11-23 05:27:01 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
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).
|
2023-12-11 11:37:27 +00:00
|
|
|
./modules/profiles/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.
|
2023-12-24 10:13:27 +00:00
|
|
|
(lib.private.getUser "nixos" "admin")
|
|
|
|
(lib.private.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-12-11 08:30:00 +00:00
|
|
|
./modules
|
2022-11-23 05:27:01 +00:00
|
|
|
];
|
|
|
|
|
2023-12-11 08:30:00 +00:00
|
|
|
# Host-specific modules structuring.
|
|
|
|
hosts.plover.services = {
|
|
|
|
# The essential services.
|
|
|
|
backup.enable = true;
|
|
|
|
database.enable = true;
|
|
|
|
firewall.enable = true;
|
|
|
|
dns-server.enable = true;
|
|
|
|
idm.enable = true;
|
|
|
|
monitoring.enable = true;
|
|
|
|
reverse-proxy.enable = true;
|
|
|
|
fail2ban.enable = true;
|
|
|
|
|
|
|
|
# The self-hosted services.
|
|
|
|
atuin.enable = true;
|
|
|
|
gitea.enable = true;
|
|
|
|
grafana.enable = true;
|
|
|
|
vaultwarden.enable = true;
|
|
|
|
wireguard.enable = true;
|
|
|
|
};
|
|
|
|
|
2023-06-30 05:38:38 +00:00
|
|
|
# Automatic format and partitioning.
|
|
|
|
disko.devices = import ./disko.nix {
|
|
|
|
disks = [ "/dev/sda" ];
|
|
|
|
};
|
|
|
|
|
2023-11-06 12:37:08 +00:00
|
|
|
# Offline SSH!?!
|
|
|
|
programs.mosh.enable = true;
|
2023-11-06 08:59:20 +00:00
|
|
|
|
2023-12-19 11:23:39 +00:00
|
|
|
sops.secrets = lib.private.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-12-18 10:04:43 +00:00
|
|
|
# Make Nix experimental.
|
|
|
|
nix.package = pkgs.nixUnstable;
|
|
|
|
|
2023-12-24 10:13:27 +00:00
|
|
|
system.stateVersion = "23.05";
|
2022-11-23 05:27:01 +00:00
|
|
|
}
|