This repository has been archived on 2023-08-08. You can view files and clone it, but cannot push or open issues or pull requests.
nil/modules/system/networking.nix

35 lines
818 B
Nix

{ config, lib, pkgs, user, ... }:
let
this = config.system.networking;
in
with lib; {
options = {
system.networking = {
enable = mkOption {
default = true;
type = with types; bool;
};
allowedPorts = mkOption {
default = with pkgs; [ 443 80 ];
type = with types; listOf port;
description = "List of ports that can be opened. Applies to both UDP and TCP";
};
};
};
config = mkIf this.enable {
networking.networkmanager.enable = true;
users.users."${user.name}".extraGroups = [ "networkmanager" ];
programs.mtr.enable = true;
networking = {
firewall = {
enable = true;
allowedTCPPorts = this.allowedPorts;
allowedUDPPorts = this.allowedPorts;
allowPing = false;
};
};
};
}