wip static net

This commit is contained in:
Evan Reichard 2025-04-08 21:25:08 -04:00
parent a1a5ee1f8f
commit 8f4e907bce
2 changed files with 48 additions and 15 deletions

View File

@ -11,6 +11,35 @@ in
enableIWD = mkEnableOption "Enable IWD"; enableIWD = mkEnableOption "Enable IWD";
useDHCP = mkBoolOpt true "Use DHCP"; useDHCP = mkBoolOpt true "Use DHCP";
useNetworkd = mkBoolOpt false "Use networkd"; useNetworkd = mkBoolOpt false "Use networkd";
useStatic = lib.mkOption {
type = lib.types.submodule {
options = {
interface = lib.mkOption {
type = lib.types.str;
description = "Network interface name";
example = "enp0s3";
};
address = lib.mkOption {
type = lib.types.str;
description = "Static IP address";
example = "10.0.20.200";
};
defaultGateway = lib.mkOption {
type = lib.types.str;
description = "Default gateway IP";
example = "10.0.20.254";
};
nameservers = lib.mkOption {
type = lib.types.listOf lib.types.str;
description = "List of DNS servers";
example = [ "10.0.20.254" "8.8.8.8" ];
default = [ "8.8.8.8" "8.8.4.4" ];
};
};
};
default = null;
description = "Static Network Configuration";
};
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
@ -24,24 +53,19 @@ in
networking = { networking = {
firewall = enabled; firewall = enabled;
useDHCP = mkDefault cfg.useDHCP; useDHCP = mkIf (cfg.useStatic == null) (mkDefault cfg.useDHCP);
useNetworkd = cfg.useNetworkd; useNetworkd = cfg.useNetworkd;
} // (lib.optionalAttrs cfg.enableIWD) { } // (lib.optionalAttrs (cfg.enableIWD) {
wireless.iwd = { wireless.iwd = {
enable = true; enable = true;
settings.General.EnableNetworkConfiguration = true; settings.General.EnableNetworkConfiguration = true;
}; };
}; }) // (lib.optionalAttrs (cfg.useStatic != null) {
inherit (cfg.useStatic) defaultGateway nameservers;
# TODO - Network Configuration interfaces.${cfg.useStatic.interface}.ipv4.addresses = [{
# (lib.mkIf (config.network != null) { inherit (cfg.useStatic) address;
# networking = { prefixLength = 24;
# inherit (config.network) defaultGateway nameservers; }];
# interfaces.${config.network.interface}.ipv4.addresses = [{ });
# inherit (config.network) address;
# prefixLength = 24;
# }];
# };
# })
}; };
} }

View File

@ -15,7 +15,16 @@ in
enable = true; enable = true;
diskPath = "/dev/xvda"; diskPath = "/dev/xvda";
}; };
networking = enabled; # TODO - Network Config networking = {
enable = true;
useDHCP = false;
useStatic = {
interface = "enX0";
address = "10.0.50.130";
defaultGateway = "10.0.50.254";
nameservers = [ "10.0.50.254" ];
};
};
}; };
services = { services = {