{ config, pkgs, ... }:

{
  imports =
    [
      /etc/nixos/hardware-configuration.nix
      ./i3.nix
    ];

  boot.kernelPackages = pkgs.linuxPackages_latest;

  nix.binaryCaches = [ https://hydra.nixos.org https://cache.nixos.org ];
  nix.trustedBinaryCaches = [ https://hydra.nixos.org https://cache.nixos.org ];
  nix.extraOptions = "auto-optimise-store = true";

  networking.networkmanager.enable = true;
  networking.firewall.enable = true;

  time.timeZone = "Europe/Vienna";

  # Select internationalisation properties.
  # i18n = {
  #   consoleFont = "lat9w-16";
  #   consoleKeyMap = "us";
  #   defaultLocale = "en_US.UTF-8";
  # };

  environment.systemPackages = with pkgs; with haskellngPackages; [
    stdenv
    nox
    wget
    vim_configurable
    zsh
    gitFull gitAndTools.hub tig gitg
    gnumake
    gmpc
    m4
    subversion
    openjdk8
    sbt scala
    idea.idea-community
    screen
    psmisc
    pkgs.parallel
    firefoxWrapper
    chromium
    thunderbird
    viewnior
    gnupg
    pass xclip pwgen
    gcc
    remmina
    silver-searcher
    tree
    python
    python34
    python34Packages.ipython
    ledger
    hledger
    hledger-diff
    cmake
    vimPlugins.YouCompleteMe
    gdb
    mpv
    bind nmap wireshark-gtk
    dstat
    which
    zip
    file
    unzip
    elinks
    ctags
    mutt
    nix-prefetch-scripts
    nix-repl

    texLiveFull biber
    androidsdk_4_4
    gimp
    inkscape
    # libreoffice
    jabref

    # haskell dev
    cabal2nix
    cabal-install
    # ghc-mod
  ];

  nixpkgs.config.packageOverrides = pkgs: rec {
    # libreoffice = pkgs.libreoffice.override { jdk = pkgs.jdk; };  # reuse package cache
    jre = pkgs.openjdk8;
    jdk = pkgs.openjdk8;
    i3 = pkgs.stdenv.lib.overrideDerivation pkgs.i3 (oldAttrs: { doCheck = false; });
  };

  environment.variables.EDITOR = "${pkgs.vim}/bin/vim";

  # Enable the OpenSSH daemon.
  services.openssh = {
    enable = true;
    permitRootLogin = "no";
    passwordAuthentication = false;
  };
  programs.ssh.startAgent = false;

  # Enable CUPS to print documents.
  services.avahi.enable = true; # cups browsing support
  services.printing.enable = true;
  # services.colord.enable = true;

  # IntelliJ
  boot.kernel.sysctl."fs.inotify.max_user_watches" = 524288;

  # gapt: `ulimit -n` was 256
  security.pam.loginLimits = [
    { domain = "*"; type = "-"; item = "nofile"; value = "4096"; }
  ];

  fileSystems."/mnt/vaccaria" = {
    device = "//vaccaria.mtlaa.gebner.org/export";
    fsType = "cifs";
    options = "noauto,x-systemd.automount,credentials=/etc/smbcredentials/vaccaria";
  };

  fileSystems."/mnt/aruanus" = {
    device = "//aruanus.htdf.gebner.org/export";
    fsType = "cifs";
    options = "noauto,x-systemd.automount,credentials=/etc/smbcredentials/aruanus";
  };

  programs.zsh = {
    enable = true;
    promptInit = "";
  };
  users.extraUsers.gebner = {
    isNormalUser = true;
    extraGroups = [ "wheel" "networkmanager" ];
    shell = "${pkgs.zsh}/bin/zsh";
  };

}