nix/packages/hosts/router.nix

180 lines
4 KiB
Nix
Raw Normal View History

2023-10-31 17:21:56 -05:00
{
2025-02-18 16:28:00 -06:00
hardware,
2024-09-13 00:38:04 -05:00
config,
2023-10-31 17:21:56 -05:00
lib,
# outputs,
2024-07-16 16:36:22 -05:00
pkgs,
2023-10-31 17:21:56 -05:00
...
2025-02-14 13:31:18 -06:00
}:
let
2025-02-18 16:28:00 -06:00
in
2025-02-18 21:53:09 -06:00
/*
NOTE: My goal is to be able to apply most of the common tweaks to the router
either live on the system for ad-hoc changes (such as forwarding a port for a
multiplayer game) or to tweak these values just below without reaching deeper
into the modules' implementation of these configuration values
NOTE: I could turn this into a cool NixOS module?
TODO: review https://francis.begyn.be/blog/nixos-home-router
TODO: more recent: https://github.com/ghostbuster91/blogposts/blob/a2374f0039f8cdf4faddeaaa0347661ffc2ec7cf/router2023-part2/main.md
*/
2025-02-18 16:28:00 -06:00
{
system.stateVersion = "24.11";
2024-07-17 16:27:54 -05:00
2025-02-18 16:28:00 -06:00
# hardware
boot = {
loader = {
efi.canTouchEfiVariables = true;
systemd-boot.enable = true;
};
initrd.availableKernelModules = [ "xhci_pci" ];
initrd.kernelModules = [ ];
kernelModules = [ "kvm-intel" ];
extraModulePackages = [ ];
};
2024-07-18 15:54:50 -05:00
2025-02-18 16:28:00 -06:00
fileSystems."/" = {
device = "/dev/disk/by-uuid/6ec80156-62e0-4f6f-b6eb-e2f588f88802";
fsType = "btrfs";
options = [ "subvol=root" ];
2024-07-16 20:34:02 -05:00
};
2025-02-18 16:28:00 -06:00
fileSystems."/nix" = {
device = "/dev/disk/by-uuid/6ec80156-62e0-4f6f-b6eb-e2f588f88802";
fsType = "btrfs";
options = [ "subvol=nix" ];
};
fileSystems."/home" = {
device = "/dev/disk/by-uuid/6ec80156-62e0-4f6f-b6eb-e2f588f88802";
fsType = "btrfs";
options = [ "subvol=home" ];
};
fileSystems."/boot" = {
device = "/dev/disk/by-uuid/7F78-7AE8";
fsType = "vfat";
options = [
"fmask=0022"
"dmask=0022"
];
};
powerManagement.cpuFreqGovernor = "performance";
2024-07-11 12:51:51 -05:00
2025-02-18 16:28:00 -06:00
imports = with hardware; [
common-cpu-intel
common-pc-ssd
2024-07-16 15:38:46 -05:00
];
2023-10-31 17:21:56 -05:00
2024-09-09 10:05:23 -05:00
environment.systemPackages = with pkgs; [
iftop
];
2024-09-13 00:38:04 -05:00
sops = {
2025-02-18 21:53:09 -06:00
defaultSopsFile = ../../secrets/router/secrets.yml;
2024-09-13 00:38:04 -05:00
age = {
2025-02-14 13:31:18 -06:00
sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
2024-09-13 00:38:04 -05:00
keyFile = "/var/lib/sops-nix/key.txt";
generateKey = true;
};
secrets = {
2025-02-14 13:31:18 -06:00
netlify-ddns-password = {
mode = "0400";
};
2024-09-13 00:38:04 -05:00
};
};
services.deno-netlify-ddns-client = {
passwordFile = config.sops.secrets.netlify-ddns-password.path;
};
2025-02-18 21:53:09 -06:00
services.openssh.listenAddresses = [
{
addr = "0.0.0.0";
port = 2201;
}
{
addr = "0.0.0.0";
port = 22;
}
{
addr = "[::]";
port = 2201;
}
{
addr = "[::]";
port = 22;
}
];
2025-02-18 16:28:00 -06:00
lyte = {
shell.enable = true;
router = {
enable = true;
hostname = "router";
domain = "h.lyte.dev";
interfaces = {
wan.mac = "00:01:2e:82:73:59";
lan.mac = "00:01:2e:82:73:5a";
};
2025-02-18 21:53:09 -06:00
2025-02-18 22:37:45 -06:00
openPorts = {
tcp = {
"Accept SSH to router" = 2201;
};
udp = {
"Accept DNS" = 53;
};
};
# TODO: nftables
2025-02-18 21:53:09 -06:00
hosts = {
dragon = {
ip = "192.168.0.10";
};
bald = {
ip = "192.168.0.11";
2025-02-18 22:37:45 -06:00
nat.tcp.minecraft = 25565;
2025-02-18 21:53:09 -06:00
additionalHosts = [
"ourcraft.lyte.dev"
];
};
beefcake = {
ip = "192.168.0.9";
2025-02-18 22:37:45 -06:00
nat = {
tcp = {
"SSH" = 22;
"HTTP" = 80;
"HTTPS" = 443;
"Minecraft Flanilla" = 26966;
};
udp = {
"QUIC" = [
80
443
];
"Factorio" = 34197;
};
};
2025-02-18 21:53:09 -06:00
additionalHosts = [
".beefcake.lan"
"a.lyte.dev"
"atuin.h.lyte.dev"
"audio.lyte.dev"
"bw.lyte.dev"
"files.lyte.dev"
"finances.h.lyte.dev"
"git.lyte.dev"
"grafana.h.lyte.dev"
"idm.h.lyte.dev"
"matrix.lyte.dev"
"nextcloud.h.lyte.dev"
"nix.h.lyte.dev"
"onlyoffice.h.lyte.dev"
"paperless.h.lyte.dev"
"prometheus.h.lyte.dev"
"video.lyte.dev"
"vpn.h.lyte.dev"
];
};
2025-02-14 13:31:18 -06:00
};
2025-02-18 16:28:00 -06:00
};
};
2023-10-31 17:21:56 -05:00
}