nixos-config/hosts/home-server.nix

171 lines
4.4 KiB
Nix
Raw Normal View History

2024-05-26 16:45:38 +02:00
{
inputs,
config,
pkgs,
...
}:
2020-09-27 14:27:25 +02:00
2021-10-23 03:06:06 +02:00
let
# mkdir /etc/secrets/initrd -p
# chmod 700 -R /etc/secrets/
# ssh-keygen -t ed25519 -N "" -f /etc/secrets/initrd/ssh_host_ed25519_key
2024-05-26 16:45:38 +02:00
hostKeys = [
{
path = "/etc/secrets/initrd/ssh_host_ed25519_key";
type = "ed25519";
}
];
in
{
2020-09-27 14:27:25 +02:00
imports = [
2023-08-13 00:28:29 +02:00
../hardware/base.nix
../desktop/x11.nix
../system/server.nix
../virtualisation/containers.nix
../virtualisation/podman.nix
../modules/inadyn.nix
2023-08-13 00:28:29 +02:00
../modules/systemdNotify.nix
../services/postgres
2023-08-13 00:28:29 +02:00
../services/mail.nix
2023-12-08 21:53:29 +01:00
../services/lldap.nix
2023-12-08 21:58:09 +01:00
../services/authelia.nix
2025-01-17 13:34:14 +01:00
../services/forgejo
2023-08-13 00:28:29 +02:00
../services/restic/home-server.nix
../services/samba/home-server.nix
# ../services/kodi.nix
../services/jellyfin.nix
../services/etebase.nix
../services/website.nix
../services/wkd.nix
../services/home-assistant
../services/matrix
../services/immich.nix
../services/miniflux.nix
../services/paperless.nix
../services/nextcloud.nix
../services/collabora-office.nix
2023-08-13 00:28:29 +02:00
../services/calibre-web.nix
2020-09-27 14:27:25 +02:00
];
2023-08-13 00:28:29 +02:00
age.secrets.cloudflare.file = ../secrets/cloudflare.age;
age.secrets.hostKey.file = ../secrets/home-server/hostKey.age;
2020-09-27 14:27:25 +02:00
nixpkgs.config.allowUnfree = true;
2020-10-03 16:23:36 +02:00
networking.domain = "home.felschr.com";
2024-05-26 16:45:38 +02:00
networking.firewall.allowedTCPPorts = [
80
443
];
networking.firewall.allowedUDPPorts = [
80
443
];
2020-10-03 16:23:36 +02:00
2022-01-01 02:06:35 +01:00
security.acme.acceptTerms = true;
security.acme.defaults.email = "dev@felschr.com";
2020-10-03 16:23:36 +02:00
services.inadyn.enable = true;
services.inadyn.provider = "cloudflare.com";
services.inadyn.username = "felschr.com";
services.inadyn.passwordFile = config.age.secrets.cloudflare.path;
services.inadyn.extraConfig = ''
proxied = false
'';
services.inadyn.ipv4.enable = true;
services.inadyn.ipv4.command = "${pkgs.writeScript "get-ipv4" ''
${pkgs.tailscale}/bin/tailscale status --json \
| ${pkgs.jq}/bin/jq -r '.Self.Addrs[0]' \
| cut -f1 -d":"
''}";
services.inadyn.ipv6.enable = true;
services.inadyn.ipv6.command = "${pkgs.writeScript "get-ipv6" ''
2024-12-08 18:22:05 +01:00
${pkgs.tailscale}/bin/tailscale status --json \
| ${pkgs.jq}/bin/jq -r '.Self.Addrs' \
| grep -o '[0-9a-f:]*::102'
''}";
services.inadyn.domains = [
"felschr.com"
"openpgpkey.felschr.com"
2023-12-08 21:53:29 +01:00
"ldap.felschr.com"
2023-12-08 21:58:09 +01:00
"auth.felschr.com"
2025-01-17 13:34:14 +01:00
"git.felschr.com"
"home.felschr.com"
"esphome.felschr.com"
"matrix.felschr.com"
"element.felschr.com"
"cloud.felschr.com"
"office.felschr.com"
"media.felschr.com"
"photos.felschr.com"
"books.felschr.com"
"news.felschr.com"
"etebase.felschr.com"
"paperless.felschr.com"
"boards.felschr.com"
];
2020-10-03 16:23:36 +02:00
2020-10-03 16:32:06 +02:00
services.nginx = {
enable = true;
recommendedTlsSettings = true;
recommendedOptimisation = true;
recommendedProxySettings = true;
recommendedZstdSettings = true;
recommendedGzipSettings = true;
recommendedBrotliSettings = true;
2020-10-03 16:32:06 +02:00
};
2020-09-27 14:27:25 +02:00
programs.zsh.enable = true;
2023-09-30 02:36:46 +02:00
programs.ssh.enableAskPassword = false;
services.openssh = {
enable = true;
2023-05-31 17:25:46 +02:00
settings = {
KbdInteractiveAuthentication = false;
PasswordAuthentication = false;
PermitRootLogin = "no";
};
2021-10-23 03:06:06 +02:00
inherit hostKeys;
};
2023-12-27 18:03:57 +01:00
services.tailscale.extraUpFlags = [
# "--accept-routes" # breaks incoming connections from outside Tailnet
2023-12-27 18:03:57 +01:00
"--advertise-tags=tag:felschr-com"
"--advertise-connector"
];
# ssh root@hostname "echo "$(read -s pass; echo \'"$pass"\')" > /crypt-ramfs/passphrase"
boot.initrd.availableKernelModules = [ "igb" ];
2021-10-23 03:06:06 +02:00
boot.initrd.network = {
enable = true;
2021-10-23 03:06:06 +02:00
ssh = {
enable = true;
hostKeys = map (f: f.path) hostKeys;
2021-10-23 03:06:06 +02:00
authorizedKeys = config.users.users.felschr.openssh.authorizedKeys.keys;
};
};
2024-06-03 19:45:03 +02:00
# allow automated decryption
# `echo -n '<LUKS passphrase here>' | clevis encrypt tang '{"url": "http://doctr:9090"}' > home-server-enc.jwe`
boot.initrd.clevis.enable = true;
boot.initrd.clevis.useTang = true;
boot.initrd.clevis.devices."enc".secretFile = ../secrets/clevis/home-server-enc.jwe;
2020-09-27 14:27:25 +02:00
systemd.notify = {
enable = true;
method = "email";
email.mailTo = "admin@felschr.com";
2024-05-26 16:45:38 +02:00
email.mailFrom = "${config.networking.hostName} <${config.programs.msmtp.accounts.default.from}>";
};
2020-09-27 14:27:25 +02:00
# only change this when specified in release notes
system.stateVersion = "24.11";
system.autoUpgrade.allowReboot = true;
system.autoUpgrade.rebootWindow = {
lower = "03:00";
upper = "05:00";
};
2020-09-27 14:27:25 +02:00
}