about summary refs log tree commit diff
path: root/modules/nixos/common/networking.nix
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--modules/nixos/common/networking.nix59
1 files changed, 30 insertions, 29 deletions
diff --git a/modules/nixos/common/networking.nix b/modules/nixos/common/networking.nix
index fb7d9b2..ecadf6e 100644
--- a/modules/nixos/common/networking.nix
+++ b/modules/nixos/common/networking.nix
@@ -5,14 +5,16 @@
   this,
   ...
 }:
-with lib; let
+with lib;
+let
   cfg = config.nixfiles.modules.common.networking;
-in {
-  options.nixfiles.modules.common.networking.onlyDefault =
-    mkEnableOption "custom networking settings";
+in
+{
+  options.nixfiles.modules.common.networking.onlyDefault = mkEnableOption "custom networking settings";
 
   config = mkIf (!cfg.onlyDefault) {
-    ark.directories = with config.networking;
+    ark.directories =
+      with config.networking;
       optional networkmanager.enable "/etc/NetworkManager/system-connections"
       ++ optional wireless.iwd.enable "/var/lib/iwd";
 
@@ -27,8 +29,8 @@ in {
         # Remove default hostname mappings. This is required at least by the
         # current implementation of the monitoring module.
         hosts = {
-          "127.0.0.2" = mkForce [];
-          "::1" = mkForce [];
+          "127.0.0.2" = mkForce [ ];
+          "::1" = mkForce [ ];
         };
 
         nameservers = mkDefault dns.const.quad9.default;
@@ -52,33 +54,35 @@ in {
           logReversePathDrops = false;
         };
       }
-      (let
-        interface = "eth0"; # This assumes `usePredictableInterfaceNames` is false.
-      in
+      (
+        let
+          interface = "eth0"; # This assumes `usePredictableInterfaceNames` is false.
+        in
         mkIf (hasAttr "ipv4" this && hasAttr "ipv6" this) {
           usePredictableInterfaceNames = false; # NOTE This can break something!
           interfaces.${interface} = {
-            ipv4.addresses = with this.ipv4;
-              optional (isString address && isInt prefixLength) {
-                inherit address prefixLength;
-              };
-
-            ipv6.addresses = with this.ipv6;
-              optional (isString address && isInt prefixLength) {
-                inherit address prefixLength;
-              };
+            ipv4.addresses =
+              with this.ipv4;
+              optional (isString address && isInt prefixLength) { inherit address prefixLength; };
+
+            ipv6.addresses =
+              with this.ipv6;
+              optional (isString address && isInt prefixLength) { inherit address prefixLength; };
           };
-          defaultGateway = with this.ipv4;
+          defaultGateway =
+            with this.ipv4;
             mkIf (isString gatewayAddress) {
               inherit interface;
               address = gatewayAddress;
             };
-          defaultGateway6 = with this.ipv6;
+          defaultGateway6 =
+            with this.ipv6;
             mkIf (isString gatewayAddress) {
               inherit interface;
               address = gatewayAddress;
             };
-        })
+        }
+      )
       (mkIf this.isHeadful {
         interfaces = {
           eth0.useDHCP = mkDefault true;
@@ -100,12 +104,8 @@ in {
     ];
 
     environment = {
-      shellAliases = listToAttrs (map
-        ({
-          name,
-          value,
-        }:
-          nameValuePair name "${pkgs.iproute2}/bin/${value}") [
+      shellAliases = listToAttrs (
+        map ({ name, value }: nameValuePair name "${pkgs.iproute2}/bin/${value}") [
           {
             name = "bridge";
             value = "bridge -color=always";
@@ -118,7 +118,8 @@ in {
             name = "tc";
             value = "tc -color=always";
           }
-        ]);
+        ]
+      );
 
       systemPackages = with pkgs; [
         ethtool

Consider giving Nix/NixOS a try! <3