mirror of
https://github.com/donovanglover/nix-config.git
synced 2025-01-24 06:38:36 +01:00
meta: Merge networking with system
This makes it easier to ensure that the system has our network settings such as random mac addresses. This makes sense since networking in general is related to the system.
This commit is contained in:
parent
8464d87cc9
commit
30f4d4f650
@ -1,62 +0,0 @@
|
||||
{ config, lib, ... }:
|
||||
|
||||
let
|
||||
inherit (lib) mkEnableOption mkOption mkIf;
|
||||
inherit (lib.types) str;
|
||||
|
||||
cfg = config.modules.networking;
|
||||
in
|
||||
{
|
||||
options.modules.networking = {
|
||||
mullvad = mkEnableOption "mullvad vpn";
|
||||
|
||||
hostName = mkOption {
|
||||
type = str;
|
||||
default = "nixos";
|
||||
};
|
||||
|
||||
allowSRB2Port = mkEnableOption "port for srb2";
|
||||
allowZolaPort = mkEnableOption "port for zola";
|
||||
};
|
||||
|
||||
config = with cfg; {
|
||||
networking = {
|
||||
inherit hostName;
|
||||
|
||||
networkmanager = {
|
||||
enable = true;
|
||||
wifi.macAddress = "random";
|
||||
ethernet.macAddress = "random";
|
||||
|
||||
unmanaged = [ "interface-name:ve-*" ];
|
||||
};
|
||||
|
||||
useHostResolvConf = true;
|
||||
|
||||
resolvconf.enable = mkIf mullvad false;
|
||||
|
||||
nat = mkIf mullvad {
|
||||
enable = true;
|
||||
internalInterfaces = [ "ve-+" ];
|
||||
externalInterface = "wg-mullvad";
|
||||
};
|
||||
|
||||
firewall = {
|
||||
allowedUDPPorts = mkIf allowSRB2Port [
|
||||
5029
|
||||
];
|
||||
|
||||
allowedTCPPorts = mkIf allowZolaPort [
|
||||
1111
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
services.resolved.llmnr = "false";
|
||||
|
||||
services.mullvad-vpn = mkIf mullvad {
|
||||
enable = true;
|
||||
enableExcludeWrapper = false;
|
||||
};
|
||||
};
|
||||
}
|
@ -4,7 +4,7 @@ let
|
||||
inherit (lib) mkOption mkEnableOption mkIf;
|
||||
inherit (lib.types) nullOr str listOf;
|
||||
inherit (pkgs.nixVersions) nix_2_19;
|
||||
inherit (cfg) username iHaveLotsOfRam hashedPassword;
|
||||
inherit (cfg) username iHaveLotsOfRam hashedPassword mullvad allowSRB2Port allowZolaPort;
|
||||
inherit (builtins) attrValues;
|
||||
|
||||
cfg = config.modules.system;
|
||||
@ -46,6 +46,16 @@ in
|
||||
};
|
||||
|
||||
iHaveLotsOfRam = mkEnableOption "tmpfs on /tmp";
|
||||
|
||||
hostName = mkOption {
|
||||
type = str;
|
||||
default = "nixos";
|
||||
};
|
||||
|
||||
mullvad = mkEnableOption "mullvad vpn";
|
||||
|
||||
allowSRB2Port = mkEnableOption "port for srb2";
|
||||
allowZolaPort = mkEnableOption "port for zola";
|
||||
};
|
||||
|
||||
config = {
|
||||
@ -158,5 +168,44 @@ in
|
||||
|
||||
boot.enableContainers = false;
|
||||
};
|
||||
|
||||
networking = {
|
||||
inherit (cfg) hostName;
|
||||
|
||||
networkmanager = {
|
||||
enable = true;
|
||||
wifi.macAddress = "random";
|
||||
ethernet.macAddress = "random";
|
||||
|
||||
unmanaged = [ "interface-name:ve-*" ];
|
||||
};
|
||||
|
||||
useHostResolvConf = true;
|
||||
|
||||
resolvconf.enable = mkIf mullvad false;
|
||||
|
||||
nat = mkIf mullvad {
|
||||
enable = true;
|
||||
internalInterfaces = [ "ve-+" ];
|
||||
externalInterface = "wg-mullvad";
|
||||
};
|
||||
|
||||
firewall = {
|
||||
allowedUDPPorts = mkIf allowSRB2Port [
|
||||
5029
|
||||
];
|
||||
|
||||
allowedTCPPorts = mkIf allowZolaPort [
|
||||
1111
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
services.resolved.llmnr = "false";
|
||||
|
||||
services.mullvad-vpn = mkIf mullvad {
|
||||
enable = true;
|
||||
enableExcludeWrapper = false;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user