{ config, lib, pkgs, ... }:

let
  inherit (pkgs) stdenv;
  spGitConfig = {
    user.email = "alan@satoshipay.io";
  };
in
{
  imports = [
    ./javascript.nix
  ];

  home.sessionVariables = {
    KUBECTX_IGNORE_FZF = "1";
  };
  home.packages = with pkgs; ([
    caddy
    openssl
    mongodb-tools
    pgcli
    s3cmd
    sops

    mkcert
    google-cloud-sdk
    docker_compose
    kubernetes
    kubectx
    kubernetes-helm
    helmfile
  ] ++ (lib.optionals (!stdenv.isDarwin)
  [
    pgadmin

    redis-desktop-manager
    robo3t
    slack
  ]));

  programs.git.includes = [
    {
      condition = "gitdir:~/projects/github.com/satoshipay/";
      contents = spGitConfig;
    }
    {
      condition = "gitdir:~/projects/gitlab.satoshipay.tech";
      contents = spGitConfig;
    }
  ];

  accounts.email.accounts.satoshipay = let
    address = "alan@satoshipay.io";
  in
  {
    inherit address;
    primary = lib.mkDefault true;
    realName = "Alan Pearce";
    flavor = "gmail.com";
    passwordCommand = "${pkgs.python3Packages.keyring}/bin/keyring get satoshipay-google-mail ${address}";
    folders = {
      inbox = "INBOX";
      drafts = "[Gmail]/Drafts";
      sent = "[Gmail]/Sent Mail";
      trash = "[Gmail]/Bin";
    };
    imap = {
      tls.enable = true;
    };
    smtp = {
      tls.enable = true;
    };
    mbsync = {
      enable = true;
      create = "maildir";
      remove = "maildir";
      expunge = "both";
    };
    msmtp = {
      enable = true;
    };
  };

  home.file.".npmrc".text = ''
    @satoshipay:registry=https://registry.npmjs.org/
  '';
}