nix-config/server-configuration.nix

127 lines
2.3 KiB
Nix
Raw Normal View History

2024-07-08 19:11:59 +02:00
{
config,
lib,
pkgs,
...
}:
let
ip = "192.168.1.177";
2024-07-11 12:25:10 +02:00
gateway = "192.168.1.1";
username = "homelab";
2024-07-08 19:11:59 +02:00
in
{
imports = [
2024-07-18 17:17:39 +02:00
./features/containers/default.nix
2024-08-12 15:56:45 +02:00
./features/multimedia/default.nix
./features/databases/default.nix
./features/services/default.nix
./features/backups.nix
./features/caddy.nix
2024-07-22 11:05:06 +02:00
./features/prometheus.nix
2024-07-15 16:27:23 +02:00
./features/samba-shares.nix
];
2024-07-08 19:11:59 +02:00
# setting up networking!!
networking = {
interfaces = {
ens18.ipv4.addresses = [
{
address = ip;
prefixLength = 24;
}
];
};
2024-07-11 12:25:10 +02:00
defaultGateway = gateway;
2024-07-08 19:11:59 +02:00
nameservers = [
"1.1.1.1"
"1.0.0.1"
];
nftables.enable = true;
# firewall rules
firewall = {
enable = true;
2024-07-08 19:37:54 +02:00
allowedTCPPorts = [
2024-07-16 15:07:52 +02:00
22 # ssh
2024-07-22 11:05:06 +02:00
8008 # matrix-synapse
8448 # matrix-synapse
5050 # calibre-web
2024-07-15 16:27:23 +02:00
9091 # transmission
2024-07-08 19:37:54 +02:00
];
2024-07-08 19:11:59 +02:00
allowedUDPPorts = [ ];
};
};
2024-07-15 16:27:23 +02:00
#TODO: setup fail2ban
services.fail2ban = {
enable = true;
ignoreIP = [ "192.168.1.0/24" ];
extraPackages = [ ];
jails = { };
};
2024-08-09 19:36:17 +02:00
2024-07-11 12:25:10 +02:00
users.groups.multimedia = {
members = [
"slskd"
"radarr"
"readarr"
"sonarr"
"transmission"
"jellyfin"
2024-07-15 16:27:23 +02:00
"bazarr"
"calibre-web"
username
2024-07-11 12:25:10 +02:00
];
};
sops.age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
2024-07-08 19:11:59 +02:00
sops.age.keyFile = "/var/lib/sops-nix/key.txt";
sops.age.generateKey = true;
2024-08-12 15:56:45 +02:00
sops.defaultSopsFile = ./secrets/secrets.yaml;
2024-07-08 19:11:59 +02:00
2024-07-11 12:25:10 +02:00
# define your secrets with
# `nix-shell -p sops --run "sops ./secrets/yoursecret.env"`
2024-07-08 19:11:59 +02:00
environment.systemPackages = with pkgs; [
jellyfin
jellyfin-web
jellyfin-ffmpeg
transmission
sonarr
radarr
prowlarr
readarr
jellyseerr
homepage-dashboard
slskd
2024-07-15 16:27:23 +02:00
bazarr
2024-08-09 12:35:21 +02:00
ethtool
networkd-dispatcher
2024-07-08 19:11:59 +02:00
];
2024-08-01 17:12:07 +02:00
system.autoUpgrade.enable = true;
system.autoUpgrade.allowReboot = true;
2024-08-12 15:56:45 +02:00
2024-07-08 19:11:59 +02:00
services.jellyfin = {
enable = true;
openFirewall = true;
};
2024-07-22 11:05:06 +02:00
services.tailscale = {
enable = true;
2024-08-09 12:35:21 +02:00
useRoutingFeatures = "server";
};
2024-08-09 19:36:17 +02:00
2024-08-09 12:35:21 +02:00
services = {
networkd-dispatcher = {
enable = true;
rules."50-tailscale" = {
2024-08-12 15:56:45 +02:00
onState = [ "routable" ];
2024-08-09 12:35:21 +02:00
script = ''
${pkgs.ethtool}/bin/ethtool -K ens18 rx-udp-gro-forwarding on rx-gro-list off
'';
};
};
2024-07-22 11:05:06 +02:00
};
2024-07-08 19:37:54 +02:00
}