nixos-config/modules/networking/default.nix

70 lines
1.5 KiB
Nix
Raw Normal View History

{ pkgs
, config
, lib
, ...
2022-03-01 22:19:03 +01:00
}:
with lib; let
cfg = config.eboskma.networking;
in
{
2021-11-21 19:07:12 +01:00
options.eboskma.networking = {
enable = mkEnableOption "activate networing settings";
dhcpInterfaces = mkOption {
description = "list of interfaces to enable DHCP on";
type = types.listOf types.nonEmptyStr;
};
2021-12-06 09:58:39 +01:00
hosts = mkOption {
description = "Additional entries to the hosts file";
type = types.attrsOf (types.listOf types.str);
};
2021-11-21 19:07:12 +01:00
};
config = mkIf (cfg.enable) {
networking = {
networkmanager.enable = true;
interfaces = listToAttrs (builtins.map
2022-03-18 21:14:51 +01:00
(iface: {
name = iface;
value = { useDHCP = true; };
2022-03-18 21:14:51 +01:00
})
cfg.dhcpInterfaces);
2021-12-06 09:58:39 +01:00
hosts = cfg.hosts;
firewall = {
trustedInterfaces = [ "lo" ];
interfaces = listToAttrs (builtins.map
2022-03-18 21:14:51 +01:00
(iface: {
name = iface;
value = {
allowedTCPPorts = [
# Horus System V2
12345
5555
5556
];
};
})
cfg.dhcpInterfaces);
};
2021-11-21 19:07:12 +01:00
};
users.extraUsers.${config.eboskma.var.mainUser}.extraGroups = [ "networkmanager" ];
2021-12-06 09:58:39 +01:00
environment.systemPackages = with pkgs; [
nmap
nmap-formatter
];
2021-12-06 09:58:39 +01:00
services.avahi = {
enable = true;
nssmdns = true;
publish = {
enable = true;
domain = true;
userServices = true;
2021-12-06 09:58:39 +01:00
};
};
2021-11-21 19:07:12 +01:00
};
}