# user.nix
{ config, pkgs, ...}:
let
  email = "klimi@sitischu.com";
in
{
 
  
  imports = [<home-manager/nixos>];
  home-manager.useUserPackages = true;
  #
  #accounts.email.accounts.klimi.address # TODO FIX
  users.users.klimi = {
    isNormalUser = true;
    extraGroups = [ "wheel" "networkmanager" "adbusers" ];
    home = "/home/klimi";
    description = "Martin Klimeš";
  };
#   services.xserver.videoDrivers = [ "nvidiaLegacy340" ];
  programs.adb.enable = true;
  
  fonts.fonts = with pkgs; [
    noto-fonts
    noto-fonts-cjk
    noto-fonts-emoji
    liberation_ttf
    fira-code
    fira-code-symbols
    mplus-outline-fonts
    dina-font
    proggyfonts
    siji
    inconsolata
  ];
  ######## POWER MANAGMENT ######
  powerManagement.enable = true;
  # powerManagement.powertop.enable = true;
  
  #powerManagement.cpuFreqGovernor = "powersave";
  ## EXPERIMENTAL ##
  nix.buildCores = 4;
  # networking.networkmanager.wifi.powersave = true;
  # powerManagement.cpufreq.max = 933000;
  # compton -b --unredir-if-possible --backend xr_glx_hybrid --vsync --use-damage --glx-no-stencil
  
  programs.bash.shellAliases = {
    nrs =
      "sudo nixos-rebuild switch -I nixos-config=/home/klimi/dotfiles/nix/configuration.nix";
    nrb =
      "sudo nixos-rebuild boot -I nixos-config=/home/klimi/dotfiles/nix/configuration.nix";
    un =
      "NIXPKGS_ALLOW_UNFREE=1 ";
  };

  

  home-manager.users.klimi = { pkgs, ... }:
    let
      unstable = import (fetchTarball
        "https://nixos.org/channels/nixos-unstable/nixexprs.tar.xz") { };
    in {
      accounts.email.accounts.klimi.address = "klimi@sitischu.com";
      accounts.email.accounts.klimi.primary = true;
      programs.alacritty.enable = true;
      home.keyboard = {
        layout = "gb";
        options = ["compose:sclk" "ctrl:nocaps"];
      };
      #############
      # syncthing #
      #############
      services.syncthing.enable = true;
      ##########
      # xcape  #
      ##########
      services.xcape.enable = true;
      # Do not map Control_L because it gets mapped too late
      # Mapping it co caps_lock suddenly works... america please explain
      services.xcape.mapExpression = { Caps_Lock="Multi_key";};
      ###########
      # polybar #
      ###########
      #services.polybar.enable = true;
      #services.polybar.config = "${dots}/polybar.config";

      #services.polybar.script = "polybar top &";

      programs.firefox.enable = true;
      home = {
        packages = [
          pkgs.ncat
          pkgs.lm_sensors
          pkgs.dunst
          pkgs.libnotify
          pkgs.bc
          pkgs.ranger
          pkgs.htop
          pkgs.stow # just stow for a workaround...
          pkgs.neofetch
          pkgs.rofi
          pkgs.xclip
          pkgs.maim
          pkgs.file
          pkgs.feh
          unstable.riot-desktop
          unstable.tdesktop
          pkgs.ghc
          pkgs.zile
          pkgs.nethogs
          pkgs.xcape
          pkgs.lemonbar-xft
          pkgs.xdotool
          pkgs.ruby
          pkgs.zsh
          pkgs.iw
          pkgs.xdo
          pkgs.emacs
          pkgs.tree
          pkgs.gotop
        ];
        #file = {
        # ".xinitrc".text = "exec bspwm";

        #};
      };
    };
}
