{ pkgs, config, lib, ... }:
{
  environment.systemPackages = [
    pkgs.mr
    pkgs.git
    pkgs.gitAndTools.hub
    pkgs.gitAndTools.git-extras
    pkgs.gitstats
    pkgs.patch
    pkgs.patchutils
    pkgs.git-quick-stats
    pkgs.git-preview
  ];

  home-manager.users.me = {
    home.file.".mrconfig".text =
    let
      prependPath = prefix: lib.attrsets.mapAttrs' (path: lib.attrsets.nameValuePair "${prefix}/${path}");
      git = url: { checkout = "git clone ${url}"; };
      github = owner: repo: git "git@github.com:${owner}/${repo}";
      keybase = owner: repo: git "keybase://private/${owner}/${repo}";
    in lib.generators.toINI {} ({
      DEFAULT = {
        git_gc = "git gc \"$@\"";
      };
    } // prependPath "prog/git" {
      "menstruation.rs" = github "kmein" "menstruation.rs";
      brockman = github "kmein" "brockman";
      challenges = github "kmein" "challenges";
      conlangs = github "kmein" "conlangs";
      ledger = keybase "kmein" "ledger";
      mahlzeit = github "kmein" "mahlzeit";
      menstruation-telegram = github "kmein" "menstruation-telegram";
      meteora = github "kmein" "meteora";
      modernizr = github "kmein" "modernizr";
      niveum = github "kmein" "niveum";
      nixpkgs = github "NixOS" "nixpkgs";
      poetry = github "kmein" "poetry";
      quotes = github "kmein" "quotes";
      sphinx = github "kmein" "sphinx";
      stockholm = git "https://cgit.krebsco.de/stockholm";
      telebots = github "kmein" "telebots";
      traadfri = github "kmein" "traadfri";
      wissen = github "kmein" "wissen";
      zen = github "kmein" "zen";
    });

    programs.git = {
      enable = true;
      package = pkgs.gitAndTools.gitFull;
      userName = config.niveum.user.name;
      userEmail = config.niveum.user.email;
      aliases = {
        br = "branch";
        co = "checkout";
        ci = "commit";
        cm = "commit -m";
        amend = "commit --amend";
        st = "status -s";
        unstage = "reset HEAD --";
        diffs = "diff --staged";
        last = "log -1 HEAD";
        logs = "log --pretty=oneline";
        graph = "log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all";
      };
      ignores = config.niveum.ignore;
    };
  };
}
