Rebase to flake parts #7

This commit is contained in:
2026-05-08 19:12:16 -03:00
parent 1015cf4577
commit f98606dcce
23 changed files with 1060 additions and 11 deletions
+90
View File
@@ -0,0 +1,90 @@
{ ... }: {
flake.nixosModules.systemNetworking = {
config,
lib,
pkgs,
...
}:
let
cfg = config.chiasson.system.networking;
in
{
options.chiasson.system.networking = {
hostName = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
example = "t2mbp";
description = "System hostname.";
};
networkManager = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Enable NetworkManager.";
};
unmanaged = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
description = "Interfaces/patterns for NetworkManager to leave unmanaged.";
};
};
wifi.tools = {
enabled = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Install Wi-Fi troubleshooting tools.";
};
packages = lib.mkOption {
type = lib.types.listOf lib.types.package;
default = with pkgs; [
iw
wirelesstools
];
description = "Wi-Fi troubleshooting packages.";
};
};
firewall = {
enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Enable host firewall.";
};
allowedTCPPorts = lib.mkOption {
type = lib.types.listOf lib.types.port;
default = [ ];
description = "TCP ports allowed through firewall.";
};
allowedUDPPorts = lib.mkOption {
type = lib.types.listOf lib.types.port;
default = [ ];
description = "UDP ports allowed through firewall.";
};
};
};
config = lib.mkMerge [
(lib.mkIf (cfg.hostName != null) {
networking.hostName = cfg.hostName;
})
(lib.mkIf cfg.networkManager.enable {
networking.networkmanager.enable = true;
networking.networkmanager.unmanaged = cfg.networkManager.unmanaged;
})
(lib.mkIf cfg.wifi.tools.enabled {
environment.systemPackages = cfg.wifi.tools.packages;
})
{
networking.firewall.enable = cfg.firewall.enable;
}
(lib.mkIf (cfg.firewall.allowedTCPPorts != [ ]) {
networking.firewall.allowedTCPPorts = cfg.firewall.allowedTCPPorts;
})
(lib.mkIf (cfg.firewall.allowedUDPPorts != [ ]) {
networking.firewall.allowedUDPPorts = cfg.firewall.allowedUDPPorts;
})
];
};
}