static net
This commit is contained in:
parent
a1a5ee1f8f
commit
4026a01425
@ -1,6 +1,6 @@
|
|||||||
{ config, lib, pkgs, namespace, ... }:
|
{ config, lib, pkgs, namespace, ... }:
|
||||||
let
|
let
|
||||||
inherit (lib) mkIf mkDefault mkEnableOption;
|
inherit (lib) types mkIf mkDefault mkOption mkEnableOption;
|
||||||
inherit (lib.${namespace}) mkBoolOpt enabled;
|
inherit (lib.${namespace}) mkBoolOpt enabled;
|
||||||
|
|
||||||
cfg = config.${namespace}.system.networking;
|
cfg = config.${namespace}.system.networking;
|
||||||
@ -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 = mkOption {
|
||||||
|
type = types.nullOr (types.submodule {
|
||||||
|
options = {
|
||||||
|
interface = mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
description = "Network interface name";
|
||||||
|
example = "enp0s3";
|
||||||
|
};
|
||||||
|
address = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = "Static IP address";
|
||||||
|
example = "10.0.20.200";
|
||||||
|
};
|
||||||
|
defaultGateway = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = "Default gateway IP";
|
||||||
|
example = "10.0.20.254";
|
||||||
|
};
|
||||||
|
nameservers = mkOption {
|
||||||
|
type = types.listOf 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;
|
|
||||||
# }];
|
|
||||||
# };
|
|
||||||
# })
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
{ namespace, config, pkgs, lib, ... }:
|
{ namespace, config, pkgs, ... }:
|
||||||
let
|
let
|
||||||
inherit (lib.${namespace}) enabled;
|
|
||||||
|
|
||||||
cfg = config.${namespace}.user;
|
cfg = config.${namespace}.user;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
time.timeZone = "America/New_York";
|
||||||
|
system.stateVersion = "24.11";
|
||||||
|
|
||||||
reichard = {
|
reichard = {
|
||||||
system = {
|
system = {
|
||||||
boot = {
|
boot = {
|
||||||
@ -15,7 +16,15 @@ in
|
|||||||
enable = true;
|
enable = true;
|
||||||
diskPath = "/dev/xvda";
|
diskPath = "/dev/xvda";
|
||||||
};
|
};
|
||||||
networking = enabled; # TODO - Network Config
|
networking = {
|
||||||
|
enable = true;
|
||||||
|
useStatic = {
|
||||||
|
interface = "enX0";
|
||||||
|
address = "10.0.50.130";
|
||||||
|
defaultGateway = "10.0.50.254";
|
||||||
|
nameservers = [ "10.0.50.254" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
services = {
|
services = {
|
||||||
@ -42,24 +51,10 @@ in
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
networking = {
|
|
||||||
defaultGateway = {
|
|
||||||
address = "10.0.50.254";
|
|
||||||
interface = "enX0";
|
|
||||||
};
|
|
||||||
interfaces.enX0.ipv4.addresses = [{
|
|
||||||
address = "10.0.50.130";
|
|
||||||
prefixLength = 24;
|
|
||||||
}];
|
|
||||||
};
|
|
||||||
|
|
||||||
# System Packages
|
# System Packages
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
htop
|
htop
|
||||||
tmux
|
tmux
|
||||||
vim
|
vim
|
||||||
];
|
];
|
||||||
|
|
||||||
time.timeZone = "America/New_York";
|
|
||||||
system.stateVersion = "24.11";
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user