this repo has no description

add cloud networking options

Diogo 03e6c2f9 dc233f8b

+113 -37
-1
.gitignore
··· 1 - hosts/heather/networking.nix
+12 -2
hosts/iris/default.nix
··· 1 1 { 2 2 imports = [ 3 3 ./hardware.nix 4 - ./networking.nix 5 4 ]; 6 5 7 6 sys = { ··· 14 13 open-webui.enable = true; 15 14 ipw-rb.enable = true; 16 15 }; 17 - networking.tailscale.enable = true; 16 + 17 + networking = { 18 + tailscale.enable = true; 19 + 20 + cloud = { 21 + interface = "ens3"; 22 + ipv4 = "51.75.255.245"; 23 + ipv6 = "2001:41d0:305:2100::7785"; 24 + gateway4 = "51.75.248.1"; 25 + gateway6 = "2001:41d0:305:2100::1"; 26 + }; 27 + }; 18 28 }; 19 29 20 30 system.stateVersion = "25.05";
-33
hosts/iris/networking.nix
··· 1 - let 2 - mainIf = "ens3"; 3 - in 4 - { 5 - networking = { 6 - useDHCP = false; 7 - 8 - interfaces.${mainIf} = { 9 - useDHCP = false; 10 - 11 - ipv4.addresses = [ 12 - { 13 - address = "51.75.255.245"; 14 - prefixLength = 32; 15 - } 16 - ]; 17 - 18 - ipv6.addresses = [ 19 - { 20 - address = "2001:41d0:305:2100::7785"; 21 - prefixLength = 128; 22 - } 23 - ]; 24 - }; 25 - 26 - defaultGateway = "51.75.248.1"; 27 - 28 - defaultGateway6 = { 29 - address = "2001:41d0:305:2100::1"; 30 - interface = mainIf; 31 - }; 32 - }; 33 - }
+99
modules/nixos/networking/cloud.nix
··· 1 + { lib, config, ... }: 2 + let 3 + inherit (lib) 4 + mkForce 5 + mkOption 6 + mkIf 7 + types 8 + ; 9 + cfg = config.sys.networking.cloud; 10 + in 11 + { 12 + options.sys.networking.cloud = { 13 + interface = mkOption { 14 + type = types.str; 15 + default = "ens3"; 16 + description = "The network interface to configure."; 17 + }; 18 + 19 + ipv4 = mkOption { 20 + type = types.nullOr types.str; 21 + default = null; 22 + description = "The IPv4 address to assign."; 23 + }; 24 + 25 + ipv6 = mkOption { 26 + type = types.nullOr types.str; 27 + default = null; 28 + description = "The IPv6 address to assign."; 29 + }; 30 + 31 + gateway4 = mkOption { 32 + type = types.nullOr types.str; 33 + default = null; 34 + description = "The IPv4 default gateway."; 35 + }; 36 + 37 + gateway6 = mkOption { 38 + type = types.nullOr types.str; 39 + default = null; 40 + description = "The IPv6 default gateway."; 41 + }; 42 + }; 43 + 44 + config = { 45 + networking = { 46 + # Apply Default Gateways only if they are defined 47 + defaultGateway = mkIf (cfg.gateway4 != null) { 48 + address = cfg.gateway4; 49 + interface = cfg.interface; 50 + }; 51 + 52 + defaultGateway6 = mkIf (cfg.gateway6 != null) { 53 + address = cfg.gateway6; 54 + interface = cfg.interface; 55 + }; 56 + 57 + dhcpcd.enable = mkForce false; 58 + useDHCP = mkForce false; 59 + 60 + # usePredictableInterfaceNames = mkForce false; 61 + 62 + interfaces.${cfg.interface} = { 63 + ipv4 = mkIf (cfg.ipv4 != null) { 64 + addresses = [ 65 + { 66 + address = cfg.ipv4; 67 + prefixLength = 32; 68 + } 69 + ]; 70 + 71 + routes = mkIf (cfg.gateway4 != null) [ 72 + { 73 + address = cfg.gateway4; 74 + prefixLength = 32; 75 + options.scope = "link"; 76 + } 77 + ]; 78 + }; 79 + 80 + ipv6 = mkIf (cfg.ipv6 != null) { 81 + addresses = [ 82 + { 83 + address = cfg.ipv6; 84 + prefixLength = 128; 85 + } 86 + ]; 87 + 88 + routes = mkIf (cfg.gateway6 != null) [ 89 + { 90 + address = cfg.gateway6; 91 + prefixLength = 128; 92 + options.scope = "link"; 93 + } 94 + ]; 95 + }; 96 + }; 97 + }; 98 + }; 99 + }
+2 -1
modules/nixos/networking/default.nix
··· 1 1 { lib, config, ... }: 2 2 let 3 - inherit (lib) mkForce mkDefault mkIf; 3 + inherit (lib) mkForce mkDefault; 4 4 in 5 5 { 6 6 imports = [ ··· 8 8 ./firewall.nix 9 9 ./openssh.nix 10 10 ./tailscale.nix 11 + ./cloud.nix 11 12 ]; 12 13 13 14 networking = {