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

with lib;
let
  name = "Niten";
  email = "niten@fudo.org";

  packages = with pkgs; [
    asdf
    atop
    binutils
    btrfs-progs
    bundix
    byobu
    cdrtools
    cargo
    curl
    doomEmacsInit
    enca
    file
    firefox
    fortune
    git
    gnupg
    guile
    imagemagick
    ipfs
    iptables
    jdk
    jq
    leiningen
    libisofs
    lispPackages.quicklisp
    lsof
    lshw
    mkpasswd
    mtr
    nixfmt
    nix-index
    nixops
    nix-prefetch-git
    nmap
    openldap
    openttd
    pciutils
    pv
    pwgen
    ruby
    rustc
    sbcl
    signal-desktop
    spotify
    stdenv
    telnet
    texlive.combined.scheme-basic
    tmux
    unzip
    xclip
    yubikey-manager
    yubikey-personalization
  ];

in {
  programs = {
    bash = { enable = true; };

    git = {
      enable = true;
      userName = name;
      userEmail = email;
      ignores = [ "*~" ];
      extraConfig = { pull = { rebase = false; }; };
    };
  };

  xresources.properties = {
    "Xft.antialias" = 1;
    "Xft.autohint" = 0;
    "Xft.dpi" = 192;
    "Xft.hinting" = 1;
    "Xft.hintstyle" = "hintfull";
    "Xft.lcdfilter" = "lcddefault";
  };

  services.gpg-agent.enable = true;

  home = {
    packages = packages;

    file = {
      ".doom.d" = {
        source = pkgs.doom-emacs-config;
        recursive = true;
        onChange = "${pkgs.doomEmacsInit}/bin/doom-emacs-init.sh";
      };

      ".local/share/openttd/baseset" = {
        source = "${pkgs.openttd-data}/data";
      };

      # ".k5login" = {
      #   source = pkgs.writeText "niten-k5login" ''
      #     niten@FUDO.ORG
      #     niten/root@FUDO.ORG
      #     niten@INFORMIS.LAND
      #     niten/root@INFORMIS.LAND
      #   '';
      # };
    };

    sessionVariables = {
      EDITOR = "emacsclient -t";
      ALTERNATE_EDITOR = "";

      HISTCONTROL = "ignoredups:ignorespace";
    };
  };
}