|
| 1 | +# ######################################################### |
| 2 | +# NIXOS (hosts) |
| 3 | +########################################################## |
| 4 | +{ inputs, config, pkgs, lib, ... }: { |
| 5 | + imports = [ |
| 6 | + # Host and hardware configuration |
| 7 | + ./hardware-configuration.nix |
| 8 | + ./disks.nix |
| 9 | + ../../nix/modules/nixos/host.nix |
| 10 | + |
| 11 | + # Users |
| 12 | + ../root.nix |
| 13 | + ../badele.nix |
| 14 | + |
| 15 | + # Commons |
| 16 | + ../../nix/nixos/features/commons |
| 17 | + ../../nix/nixos/features/homelab |
| 18 | + ../../nix/nixos/features/system/containers.nix |
| 19 | + |
| 20 | + # Roles |
| 21 | + ../../nix/nixos/roles # Automatically load service from <host.modules> sectionn from `homelab.json` file |
| 22 | + ]; |
| 23 | + |
| 24 | + #################################### |
| 25 | + # Boot |
| 26 | + #################################### |
| 27 | + |
| 28 | + boot = { |
| 29 | + kernelParams = [ "mem_sleep_default=deep" ]; |
| 30 | + blacklistedKernelModules = [ ]; |
| 31 | + kernelModules = [ "kvm-intel" ]; |
| 32 | + supportedFilesystems = [ "btrfs" ]; |
| 33 | + |
| 34 | + # Grub EFI boot loader |
| 35 | + loader = { |
| 36 | + grub = { |
| 37 | + enable = true; |
| 38 | + devices = [ "nodev" ]; |
| 39 | + efiInstallAsRemovable = true; |
| 40 | + efiSupport = true; |
| 41 | + useOSProber = true; |
| 42 | + }; |
| 43 | + }; |
| 44 | + |
| 45 | + # Network |
| 46 | + kernel = { |
| 47 | + sysctl = { |
| 48 | + # Forward on all ipv4 interfaces. |
| 49 | + "net.ipv4.conf.all.forwarding" = true; |
| 50 | + }; |
| 51 | + }; |
| 52 | + }; |
| 53 | + |
| 54 | + # xorg |
| 55 | + # videoDrivers = [ "intel" "i965" "nvidia" ]; |
| 56 | + |
| 57 | + #################################### |
| 58 | + # host profile |
| 59 | + #################################### |
| 60 | + hostprofile = { nproc = 8; }; |
| 61 | + |
| 62 | + virtualisation.docker.storageDriver = "btrfs"; |
| 63 | + |
| 64 | + #################################### |
| 65 | + # Hardware |
| 66 | + #################################### |
| 67 | + |
| 68 | + # Pulseaudio |
| 69 | + hardware.pulseaudio = { |
| 70 | + enable = true; |
| 71 | + support32Bit = |
| 72 | + true; # # If compatibility with 32-bit applications is desired |
| 73 | + #extraConfig = "load-module module-combine-sink"; |
| 74 | + }; |
| 75 | + |
| 76 | + #################################### |
| 77 | + # Networking |
| 78 | + #################################### |
| 79 | + |
| 80 | + networking = { |
| 81 | + enableIPv6 = false; |
| 82 | + hostName = "hype16"; |
| 83 | + useDHCP = false; |
| 84 | + |
| 85 | + # Define VLANs |
| 86 | + vlans = { |
| 87 | + vlandmz = { |
| 88 | + id = 32; |
| 89 | + interface = "enp1s0"; # tagged |
| 90 | + }; |
| 91 | + vlanadm = { |
| 92 | + id = 240; |
| 93 | + interface = "enp1s0"; # tagged |
| 94 | + }; |
| 95 | + }; |
| 96 | + |
| 97 | + # Create interfaces |
| 98 | + interfaces = { |
| 99 | + brlan = { |
| 100 | + ipv4.addresses = [{ |
| 101 | + address = "192.168.254.16"; |
| 102 | + prefixLength = 24; |
| 103 | + }]; |
| 104 | + }; |
| 105 | + |
| 106 | + bradm = { |
| 107 | + ipv4.addresses = [{ |
| 108 | + address = "192.168.240.16"; |
| 109 | + prefixLength = 24; |
| 110 | + }]; |
| 111 | + }; |
| 112 | + |
| 113 | + brdmz = { |
| 114 | + ipv4.addresses = [{ |
| 115 | + address = "192.168.32.16"; |
| 116 | + prefixLength = 24; |
| 117 | + }]; |
| 118 | + }; |
| 119 | + }; |
| 120 | + |
| 121 | + # Create bridges |
| 122 | + bridges = { |
| 123 | + # untagged |
| 124 | + "brlan" = { interfaces = [ "enp1s0" ]; }; |
| 125 | + "bradm" = { interfaces = [ "vlanadm" ]; }; |
| 126 | + "brdmz" = { interfaces = [ "vlandmz" ]; }; |
| 127 | + }; |
| 128 | + |
| 129 | + # Define default gateway and nameservers |
| 130 | + defaultGateway = "192.168.254.254"; |
| 131 | + nameservers = [ "89.2.0.1" "89.2.0.2" ]; |
| 132 | + }; |
| 133 | + |
| 134 | + #################################### |
| 135 | + # Incus hypervisor |
| 136 | + #################################### |
| 137 | + |
| 138 | + networking.nftables.enable = true; |
| 139 | + |
| 140 | + networking.firewall = { |
| 141 | + # logReversePathDrops = true; |
| 142 | + # logRefusedPackets = true; |
| 143 | + # logRefusedConnections = true; |
| 144 | + # logRefusedUnicastsOnly = true; |
| 145 | + |
| 146 | + interfaces = { |
| 147 | + brdmz = { |
| 148 | + allowedTCPPorts = [ 53 67 ]; |
| 149 | + allowedUDPPorts = [ 53 67 ]; |
| 150 | + }; |
| 151 | + |
| 152 | + }; |
| 153 | + |
| 154 | + # Forward |
| 155 | + # filterForward = true; |
| 156 | + # extraForwardRules = "iifname brdmz oifname brdmz accept"; |
| 157 | + extraInputRules = "iifname brdmz accept"; |
| 158 | + # "iifname brdmz ip saddr 192.168.254.0/24 ip daddr 192.168.253.0/24 accept"; |
| 159 | + }; |
| 160 | + |
| 161 | + virtualisation.incus = { |
| 162 | + enable = true; |
| 163 | + ui.enable = true; |
| 164 | + preseed = { |
| 165 | + profiles = [ |
| 166 | + { |
| 167 | + name = "default"; |
| 168 | + description = "Default profile"; |
| 169 | + devices = { |
| 170 | + eth0 = { |
| 171 | + name = "eth0"; |
| 172 | + type = "nic"; |
| 173 | + nictype = "bridged"; |
| 174 | + parent = "brlan"; |
| 175 | + }; |
| 176 | + root = { |
| 177 | + path = "/"; |
| 178 | + pool = "default"; |
| 179 | + size = "35GiB"; |
| 180 | + type = "disk"; |
| 181 | + }; |
| 182 | + }; |
| 183 | + } |
| 184 | + { |
| 185 | + name = "lan"; |
| 186 | + description = "LAN profile"; |
| 187 | + devices = { |
| 188 | + eth0 = { |
| 189 | + name = "eth0"; |
| 190 | + type = "nic"; |
| 191 | + nictype = "bridged"; |
| 192 | + parent = "brlan"; |
| 193 | + }; |
| 194 | + }; |
| 195 | + } |
| 196 | + { |
| 197 | + name = "dmz"; |
| 198 | + description = "DMZ profile"; |
| 199 | + devices = { |
| 200 | + eth1 = { |
| 201 | + name = "eth1"; |
| 202 | + type = "nic"; |
| 203 | + nictype = "bridged"; |
| 204 | + parent = "brdmz"; |
| 205 | + }; |
| 206 | + }; |
| 207 | + } |
| 208 | + ]; |
| 209 | + storage_pools = [{ |
| 210 | + config = { source = "/var/lib/incus/storage-pools/default"; }; |
| 211 | + driver = "dir"; |
| 212 | + name = "default"; |
| 213 | + }]; |
| 214 | + }; |
| 215 | + }; |
| 216 | + |
| 217 | + #################################### |
| 218 | + # Storage |
| 219 | + #################################### |
| 220 | + systemd.tmpfiles.rules = [ |
| 221 | + # trilium app |
| 222 | + "d /data/incus/trilium/var_lib_trilium 0750 root root -" |
| 223 | + ]; |
| 224 | + |
| 225 | + #################################### |
| 226 | + # Programs |
| 227 | + #################################### |
| 228 | + powerManagement.powertop.enable = true; |
| 229 | + programs = { }; |
| 230 | + |
| 231 | + nixpkgs.hostPlatform.system = "x86_64-linux"; |
| 232 | + system.stateVersion = "24.05"; |
| 233 | +} |
0 commit comments