nix-config/home/git/default.nix

126 lines
2.9 KiB
Nix
Raw Normal View History

2021-02-19 23:16:22 +01:00
{ pkgs, lib, ... }:
2021-02-19 22:48:25 +01:00
{
programs.git = {
enable = true;
# Who am I?
userEmail = "bruno@belanyi.fr";
userName = "Bruno BELANYI";
# I want the full experience
package = pkgs.gitAndTools.gitFull;
aliases = {
lol = "log --graph --decorate --pretty=oneline --abbrev-commit";
lola = "lol --all";
assume = "update-index --assume-unchanged";
unassume = "update-index --no-assume-unchanged";
assumed = "!git ls-files -v | grep ^h | cut -c 3-";
push-new = "!git push -u origin "
+ ''"$(git branch | grep '^* ' | cut -f2- -d' ')"'';
};
lfs.enable = true;
# There's more
extraConfig = {
# Makes it a bit more readable
blame = {
coloring = "repeatedLines";
markUnblamables = true;
markIgnoredLines = true;
};
# I want `pull --rebase` as a default
branch = {
autosetubrebase = "always";
};
# Shiny colors
color = {
ui = "auto";
branch = "auto";
diff = "auto";
interactive = "auto";
status = "auto";
};
# Pretty much the usual diff colors
"color.diff" = {
commit = "yellow";
meta = "yellow";
frag = "cyan";
old = "red";
new = "green";
whitespace = "red reverse";
};
"color.diff-highlight" = {
oldNormal = "red bold";
oldHighlight = "red bold 52";
newNormal = "green bold";
newHighlight = "green bold 22";
};
2021-02-19 22:48:25 +01:00
commit = {
# Show my changes when writing the message
verbose = true;
};
diff = {
# Usually leads to better results
algorithm = "patience";
};
fetch = {
# I don't want hanging references
prune = true;
pruneTags = true;
};
init = {
defaultBranch = "main";
};
2021-02-20 14:30:09 +01:00
pager =
let
diff-highlight = "${pkgs.gitAndTools.gitFull}/share/git/contrib/diff-highlight/diff-highlight";
in
{
diff = "${diff-highlight} | less";
log = "${diff-highlight} | less";
show = "${diff-highlight} | less";
};
2021-02-19 22:48:25 +01:00
pull = {
# Avoid useless merge commits
rebase = true;
};
push = {
# Just yell at me instead of trying to be smart
default = "simple";
};
rebase = {
# Why isn't it the default?...
autoSquash = true;
autoStash = true;
};
};
# Multiple identities
includes = [
{ path = ./epita.config; condition = "gitdir:~/git/EPITA/"; }
];
2021-02-19 23:16:22 +01:00
ignores =
let
readLines = file: lib.splitString "\n" (builtins.readFile file);
removeComments = lib.filter (line: line != "" && !(lib.hasPrefix "#" line));
getPaths = file: removeComments (readLines file);
in
getPaths ./default.ignore;
2021-02-19 22:48:25 +01:00
};
}