{ config, lib, ... }:
let
  always = 100;
  home = 99;
  public_wifi = false;
in
{
  imports = lib.optionals (!public_wifi) [
    ./private-wifi.nix
  ];
  networking.wireless = {
    enable = true;
    secretsFile = config.sops.secrets."wifi-env".path;
    userControlled.enable = true;
    networks = {
      "taetaethegae-2.0" = {
        pskRaw = "ext:PASS_taetaethegae_20";
        priority = home;
      };
      "k" = {
        pskRaw = "ext:PASS_k";
        priority = always;
      };
      "Bloomfield".pskRaw = "ext:PASS_bloomfield";
      "9872441500".pskRaw = "ext:PASS_longboat_home";
      "9872441561".pskRaw = "ext:PASS_longboat_home";
      "5HuFios".pskRaw = "ext:PASS_longboat_home";
      "24HuFios".pskRaw = "ext:PASS_longboat_home";
      "Verizon_ZLHQ3H".pskRaw = "ext:PASS_angie";
      "Fios-Qn3RB".pskRaw = "ext:PASS_parkridge";
      "Mojo Dojo Casa House".pskRaw = "ext:PASS_Carly";

      # Public wifi connections
      # set public_wifi on line 5 to true if connecting to one of these
      #"optimumwifi" = { };
      #"CableWiFi" = { };
      #"Hilton Honors" = { };

      # Work wifi
      "JPMCVisitor" = { };
    };
  };

  sops = {
    defaultSopsFile = ./secrets.yaml;
    secrets = {
      "wifi-env" = {
        owner = "root";
        restartUnits = [ "wpa_supplicant.service" ];
      };
    };
  };
}