{ lib, config, ... }:
let
  hostname = "pi4";
in
{
  # Networking configs
  networking = {
    hostName = hostname;

    defaultGateway.address = "10.0.1.1";
    nameservers = [ "10.0.1.1" ];

    firewall = {
      enable = true;
      allowPing = true;
      allowedTCPPorts = [ 53 ];
      allowedUDPPorts = [ 53 ];
    };

    # Enable Network Manager
    networkmanager = {
      enable = lib.mkDefault true;
      wifi.powersave = lib.mkDefault false;
      settings.connectivity.uri = lib.mkDefault "http://nmcheck.gnome.org/check_network_status.txt";
      ensureProfiles = {
        environmentFiles = [
         config.sops.secrets.wifi.path
        ];

        profiles = {
          # "Joey's Jungle 5G" = {
          #   connection = {
          #     id = "Joey's Jungle 5G";
          #     type = "wifi";
          #   };
          #   ipv4 = {
          #     method = "auto";
          #   };
          #   ipv6 = {
          #     addr-gen-mode = "stable-privacy";
          #     method = "auto";
          #   };
          #   wifi = {
          #     mode = "infrastructure";
          #     ssid = "Joey's Jungle 5G";
          #   };
          #   wifi-security = {
          #     key-mgmt = "sae";
          #     psk = "$PSK";
          #   };
          # };

          "static-enabcm6e4ei0" = {
            connection = {
              id = "static-enabcm6e4ei0";
              type = "ethernet";
              interface-name = "enabcm6e4ei0";
            };

            ipv4 = {
              method = "manual";
              address = "10.0.1.2/24";
              gateway = "10.0.1.1";
              dns = "1.1.1.1";
            };
            ipv6 = {
              addr-gen-mode = "stable-privacy";
              method = "auto";
            };
          };
        };
      };
    };
  };
}
