diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-05-20 16:10:21 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-05-20 16:14:26 +0200 |
commit | 368cb6b0d25db2ae23be42ad51584de059997e51 (patch) | |
tree | 3282e45d3ebced63c8498a47e83a255c35de620b /modules/system/networking/default.nix | |
parent | refactor(hm): Rename to `modules/home` (diff) | |
download | nixos-config-368cb6b0d25db2ae23be42ad51584de059997e51.tar.gz nixos-config-368cb6b0d25db2ae23be42ad51584de059997e51.zip |
refactor(sys): Modularize and move to `modules/system` or `pkgs`
Diffstat (limited to 'modules/system/networking/default.nix')
-rw-r--r-- | modules/system/networking/default.nix | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/modules/system/networking/default.nix b/modules/system/networking/default.nix new file mode 100644 index 00000000..aaaab782 --- /dev/null +++ b/modules/system/networking/default.nix @@ -0,0 +1,81 @@ +{ + config, + lib, + ... +}: let + cfg = config.soispha.networking; +in { + options.soispha.networking = { + enable = lib.mkEnableOption "networking"; + + networkManager = { + enable = lib.mkEnableOption "NetworkManager"; + }; + + hostName = lib.mkOption { + type = lib.types.str; + example = "apzu"; + description = "The name of the host"; + }; + }; + + config = + lib.mkIf cfg.enable { + systemd.network = { + networks = { + "tap0" = { + name = "tap0"; + bridge = [ + "virbr0" + ]; + }; + "enp4s0" = { + name = "enp4s0"; + networkConfig = { + DHCP = "yes"; + DNSOverTLS = "yes"; + DNSSEC = "yes"; + }; + bridge = [ + "virbr0" + ]; + }; + }; + + netdevs = { + "tap0" = { + netdevConfig = { + Name = "tap0"; + Kind = "tap"; + }; + tapConfig = { + User = "${config.users.users.soispha.uid}"; + Group = "libvirtd"; + }; + }; + "virbr0" = { + netdevConfig = { + Name = "br0"; + Kind = "bridge"; + }; + }; + }; + }; + } + // lib.mkIf cfg.networkManager.enable { + networking = { + networkmanager = { + enable = true; + dns = "default"; + wifi = { + powersave = true; + }; + }; + inherit (cfg) hostName; + }; + + users.users.soispha.extraGroups = [ + "networkmanager" # allows to configure networkmanager as this user + ]; + }; +} |