{ pkgs, fetchurl, ... }:

{
	imports = [
                ../progs/alacritty
		../progs/i3
		../progs/i3status-rust
                ../progs/kitty
		../progs/neovim
	];

	# Let Home Manager install and manage itself.
	programs.home-manager.enable = true;

	services.dunst.enable = true;

        nixpkgs.overlays = [ (final: prev: {
            go_1_18 = prev.go_1_17.overrideAttrs (old: rec {
              version="1.18beta1";
              src = prev.fetchurl {
                url = "https://dl.google.com/go/go${version}.src.tar.gz";
                sha256 = "sha256-QYwCjbFGmctbLUkHrTpBnXn3ibMZFu+HZIZ+SnjmU6E=";
              };
              patches = builtins.filter (
                x: !(builtins.isList (builtins.match ".*/go-1.9-skip-flaky-20072.patch" (builtins.toString x)))
              ) old.patches;
            });
          })

          (final: prev: {
            gopls = prev.gopls.override {
              buildGoModule = prev.buildGoModule.override {
                go = final.go_1_18;
              };
            };
          })

        ];

	home = {
		username = "daniel";
		homeDirectory = "/home/daniel";
		sessionVariables = {
			EDITOR = "vim";
		};
                sessionPath = [
                  "$HOME/go/bin"
                ];

		file = {
			".icons/default".source = "${pkgs.capitaine-cursors}/share/icons/capitaine-cursors";

			"bin/supdate" = {
				source = ../../scripts/supdate;
				executable = true;
			};

			"bin/hmupdate" = {
				source = ../../scripts/hmupdate;
				executable = true;
			};

			"bin/update" = {
				source = ../../scripts/update;
				executable = true;
			};

			"bin/aupdate" = {
				source = ../../scripts/aupdate;
				executable = true;
			};
		};

		packages = with pkgs; [
                        _1password
			discord
			element-desktop
			entr
			feh
			fzf
                        go_1_18
			google-drive-ocamlfuse
			gomuks
			gopls
			i3
			i3lock
			i3utils
			iosevka
			mpv
			nerdfonts
			oh-my-zsh
			pavucontrol
			playerctl
			python3
                        spotify
			ranger
			restic
			rofi
			starship
			xclip
		];

		keyboard = {
			layout = "gb";
			options = [
				"caps:escape"
			];
		};

		stateVersion = "21.05";
	};

	programs = {

		git = {
			enable = true;
			userName = "Daniel Patterson";
			userEmail = "me@danielpatterson.dev";
			extraConfig = {
				pull.rebase = true;
				init.defaultBranch = "main";
			};
		};

		lazygit = {
			enable = true;
			settings = {
				gui = {
					showFileTree = false;
				};
			};
		};

		starship.enable = true;

		vscode.enable = true;

		zsh = {
			enable = true;
			enableAutosuggestions = true;
			oh-my-zsh = {
				enable = true;
				plugins = [ "git" "fzf" ];
				theme = "agnoster";
			};
		};
	};
}
