nixos/modules/hosts/robin/configuration.nix

163 lines
4.7 KiB
Nix
Raw Normal View History

2026-06-05 15:11:46 -04:00
{ self, inputs, ... }: {
2026-06-11 15:38:01 -04:00
flake.nixosModules.robinConfiguration = { pkgs, config, ... }: {
2026-06-05 15:11:46 -04:00
imports = [
self.nixosModules.robinHardware
self.nixosModules.nest
self.nixosModules.git
self.nixosModules.zsh
];
environment.systemPackages = with pkgs; [
kubectl
htop
zip
unzip
dig
traceroute
neovim
wget
2026-06-11 15:38:01 -04:00
openiscsi # Required for longhorn
nfs-utils
2026-06-05 15:11:46 -04:00
];
networking.networkmanager.enable = true;
networking.hostName = "robin";
services = {
openssh.enable = true;
2026-06-11 15:38:01 -04:00
openiscsi.enable = true;
openiscsi.name = "iqn.2005-10.nixos:${config.networking.hostName}";
envfs.enable = true;
};
# Enable K3s in Agent Mode
services.k3s = {
enable = true;
role = "agent";
2026-07-04 10:42:10 -04:00
package = pkgs.k3s_1_36;
2026-06-11 15:38:01 -04:00
serverAddr = "https://192.168.1.122:6443";
tokenFile = "/var/lib/rancher/k3s/join-token";
2026-06-05 15:11:46 -04:00
};
2026-06-11 15:38:01 -04:00
# Fix non-FHS paths for longhorn
# This creates persistent symlinks where Longhorn expects to find them.
systemd.tmpfiles.rules = [
2026-06-17 11:47:18 -04:00
# Core mount utilities (provide both /bin and /usr/bin paths)
"L+ /bin/mount - - - - /run/current-system/sw/bin/mount"
"L+ /usr/bin/mount - - - - /run/current-system/sw/bin/mount"
2026-06-18 18:41:34 -04:00
"L+ /sbin/mount - - - - /run/current-system/sw/bin/mount"
2026-06-17 11:47:18 -04:00
"L+ /bin/umount - - - - /run/current-system/sw/bin/umount"
"L+ /usr/bin/umount - - - - /run/current-system/sw/bin/umount"
"L+ /bin/nsenter - - - - /run/current-system/sw/bin/nsenter"
"L+ /usr/bin/nsenter - - - - /run/current-system/sw/bin/nsenter"
# NFS Mount Helpers (Crucial for Longhorn Share-Manager / RWX volumes)
"L+ /sbin/mount.nfs - - - - /run/current-system/sw/bin/mount.nfs"
"L+ /sbin/umount.nfs - - - - /run/current-system/sw/bin/umount.nfs"
"L+ /usr/sbin/mount.nfs - - - - /run/current-system/sw/bin/mount.nfs"
"L+ /usr/sbin/umount.nfs - - - - /run/current-system/sw/bin/umount.nfs"
2026-06-18 18:41:34 -04:00
# NFSv4 specific helpers required by Longhorn RWX
"L+ /sbin/mount.nfs4 - - - - /run/current-system/sw/bin/mount.nfs4"
"L+ /sbin/umount.nfs4 - - - - /run/current-system/sw/bin/umount.nfs4"
"L+ /usr/sbin/mount.nfs4 - - - - /run/current-system/sw/bin/mount.nfs4"
"L+ /usr/sbin/umount.nfs4 - - - - /run/current-system/sw/bin/umount.nfs4"
2026-06-11 15:38:01 -04:00
];
2026-06-08 15:57:00 -04:00
# RAID
boot.swraid = {
enable = true;
mdadmConf = ''
2026-06-08 17:26:29 -04:00
MAILADDR root
2026-06-08 15:57:00 -04:00
ARRAY /dev/md0 level=raid10 num-devices=4 metadata=1.2 UUID=f94b90a5:574f242f:00596ed9:a2b369c7
'';
};
fileSystems."/mnt/raid" = {
device = "/dev/disk/by-uuid/208bee23-4723-42c2-ac4e-c902eb530f80";
fsType = "ext4";
2026-06-08 17:26:29 -04:00
options = [ "defaults" "nofail" ];
};
# NFS
services.nfs = {
server.enable = true;
server.exports = ''
/export/yarr 192.168.1.0/16(rw,secure,anonuid=1000,anongid=1000,all_squash)
2026-06-26 18:17:20 -04:00
/export/nextcloud 192.168.1.0/16(rw,secure,no_root_squash)
2026-06-08 17:26:29 -04:00
/export 192.168.1.0/16(ro,fsid=0,root_squash,subtree_check,secure)
'';
2026-06-08 17:43:44 -04:00
# Pin the ports
server.statdPort = 4000;
server.lockdPort = 4001;
server.mountdPort = 4002;
2026-06-08 15:57:00 -04:00
};
fileSystems."/export/yarr" = {
device = "/mnt/raid/yarr";
2026-06-08 17:26:29 -04:00
fsType = "ext4";
2026-06-08 15:57:00 -04:00
options = [ "bind" ];
};
2026-06-26 18:17:20 -04:00
fileSystems."/export/nextcloud" = {
device = "/mnt/raid/nextcloud";
fsType = "ext4";
options = [ "bind" ];
};
2026-06-08 15:57:00 -04:00
2026-06-08 17:43:44 -04:00
networking.firewall = {
enable = true;
allowedTCPPorts = [
22 # SSH (CRITICAL: Do not remove)
# --- NFS Ports ---
111 2049 4000 4001 4002
# --- K3s Agent Ports ---
10250 # Kubelet API (Required for master node logs/metrics/exec)
2026-06-11 15:53:50 -04:00
9100 # Prometheus Node Exporter
2026-06-08 17:43:44 -04:00
];
allowedUDPPorts = [
# --- NFS Ports ---
111 2049 4000 4001 4002
# --- K3s Agent Ports ---
8472 # Flannel VXLAN overlay networking (Required for pod-to-pod communication)
];
};
2026-06-05 15:11:46 -04:00
boot = {
loader = {
systemd-boot.enable = true;
efi.canTouchEfiVariables = true;
timeout = 1;
};
kernelPackages = pkgs.linuxPackages_latest;
2026-06-08 15:57:00 -04:00
supportedFilesystems = [ "nfs" ];
2026-06-05 15:11:46 -04:00
};
time.timeZone = "America/New_York";
time.hardwareClockInLocalTime = false;
nix.settings.experimental-features = [ "nix-command" "flakes" ];
nix.settings.auto-optimise-store = true;
nix.gc = {
automatic = true;
dates = "weekly";
options = "--delete-older-than 30d";
};
nixpkgs.config.allowUnfree = true;
system.stateVersion = "26.05";
};
}