Refactor of the networking part.

Added new option. `config.system.networking.allowedPorts` as well as a
boolean for enabling/disabling this.
This commit is contained in:
James Patrick 2022-08-14 20:33:40 -04:00
parent 95e6223340
commit 7f015d342f
2 changed files with 31 additions and 10 deletions

View File

@ -1,11 +1,34 @@
{ config, lib, pkgs, ... }: {
programs.mtr.enable = true;
networking = {
firewall = {
enable = true;
allowedTCPPorts = [ 443 80 ];
allowedUDPPorts = [ 443 80 ];
allowPing = false;
{ 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;
};
};
};
}

View File

@ -1,6 +1,4 @@
{ config, lib, pkgs, user, ... }: {
imports = [ ./graphical.nix ];
my.system.boot.enable = true;
networking.networkmanager.enable = true;
users.users."${user.name}".extraGroups = [ "networkmanager" ];
}