2021-03-13 01:01:20 +01:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.my.home.git;
|
2021-10-12 17:55:48 +02:00
|
|
|
|
|
|
|
inherit (lib.my) mkMailAddress;
|
2021-03-13 01:01:20 +01:00
|
|
|
in
|
2021-02-19 22:48:25 +01:00
|
|
|
{
|
2023-03-16 17:39:13 +01:00
|
|
|
options.my.home.git = with lib; {
|
|
|
|
enable = my.mkDisableOption "git configuration";
|
2021-03-13 01:01:20 +01:00
|
|
|
};
|
|
|
|
|
2022-09-29 21:58:48 +02:00
|
|
|
config.home.packages = with pkgs; lib.mkIf cfg.enable [
|
|
|
|
git-absorb
|
|
|
|
git-revise
|
|
|
|
tig
|
2021-10-12 21:32:13 +02:00
|
|
|
];
|
|
|
|
|
2021-03-13 01:01:20 +01:00
|
|
|
config.programs.git = lib.mkIf cfg.enable {
|
2021-02-19 22:48:25 +01:00
|
|
|
enable = true;
|
|
|
|
|
|
|
|
# Who am I?
|
2021-10-12 17:55:48 +02:00
|
|
|
userEmail = mkMailAddress "bruno" "belanyi.fr";
|
2021-02-19 22:48:25 +01:00
|
|
|
userName = "Bruno BELANYI";
|
|
|
|
|
|
|
|
# I want the full experience
|
2022-09-29 21:58:48 +02:00
|
|
|
package = pkgs.gitFull;
|
2021-02-19 22:48:25 +01:00
|
|
|
|
|
|
|
aliases = {
|
2021-10-12 16:33:33 +02:00
|
|
|
git = "!git";
|
2021-07-13 17:50:41 +02:00
|
|
|
lol = "log --graph --decorate --pretty=oneline --abbrev-commit --topo-order";
|
2021-02-19 22:48:25 +01:00
|
|
|
lola = "lol --all";
|
|
|
|
assume = "update-index --assume-unchanged";
|
|
|
|
unassume = "update-index --no-assume-unchanged";
|
|
|
|
assumed = "!git ls-files -v | grep ^h | cut -c 3-";
|
2021-05-25 20:26:37 +02:00
|
|
|
pick = "log -p -G";
|
2021-02-19 22:48:25 +01:00
|
|
|
push-new = "!git push -u origin "
|
|
|
|
+ ''"$(git branch | grep '^* ' | cut -f2- -d' ')"'';
|
2023-03-14 18:00:31 +01:00
|
|
|
root = "git rev-parse --show-toplevel";
|
2021-02-19 22:48:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
lfs.enable = true;
|
|
|
|
|
2021-03-20 00:17:49 +01:00
|
|
|
delta = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
options = {
|
|
|
|
features = "diff-highlight decorations";
|
|
|
|
|
|
|
|
# Less jarring style for `diff-highlight` emulation
|
|
|
|
diff-highlight = {
|
|
|
|
minus-style = "red";
|
|
|
|
minus-non-emph-style = "red";
|
|
|
|
minus-emph-style = "bold red 52";
|
|
|
|
|
|
|
|
plus-style = "green";
|
|
|
|
plus-non-emph-style = "green";
|
|
|
|
plus-emph-style = "bold green 22";
|
|
|
|
|
|
|
|
whitespace-error-style = "reverse red";
|
|
|
|
};
|
|
|
|
|
|
|
|
# Personal preference for easier reading
|
|
|
|
decorations = {
|
2021-12-06 21:24:31 +01:00
|
|
|
commit-style = "raw"; # Do not recolor meta information
|
2021-03-20 00:17:49 +01:00
|
|
|
keep-plus-minus-markers = true;
|
|
|
|
paging = "always";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-02-19 22:48:25 +01:00
|
|
|
# There's more
|
|
|
|
extraConfig = {
|
|
|
|
# Makes it a bit more readable
|
|
|
|
blame = {
|
|
|
|
coloring = "repeatedLines";
|
|
|
|
markIgnoredLines = true;
|
2021-03-15 21:52:12 +01:00
|
|
|
markUnblamables = true;
|
2021-02-19 22:48:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
# I want `pull --rebase` as a default
|
|
|
|
branch = {
|
|
|
|
autosetubrebase = "always";
|
|
|
|
};
|
|
|
|
|
|
|
|
# Shiny colors
|
|
|
|
color = {
|
|
|
|
branch = "auto";
|
|
|
|
diff = "auto";
|
|
|
|
interactive = "auto";
|
|
|
|
status = "auto";
|
2021-03-15 21:52:12 +01:00
|
|
|
ui = "auto";
|
2021-02-19 22:48:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
# Pretty much the usual diff colors
|
|
|
|
"color.diff" = {
|
|
|
|
commit = "yellow";
|
|
|
|
frag = "cyan";
|
2021-03-15 21:52:12 +01:00
|
|
|
meta = "yellow";
|
2021-02-19 22:48:25 +01:00
|
|
|
new = "green";
|
2021-03-15 21:52:12 +01:00
|
|
|
old = "red";
|
2021-02-19 22:48:25 +01:00
|
|
|
whitespace = "red reverse";
|
|
|
|
};
|
|
|
|
|
|
|
|
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";
|
|
|
|
};
|
|
|
|
|
2023-02-08 15:31:29 +01:00
|
|
|
# Local configuration, not-versioned
|
|
|
|
include = {
|
|
|
|
path = "config.local";
|
|
|
|
};
|
|
|
|
|
2022-03-11 14:10:04 +01:00
|
|
|
merge = {
|
|
|
|
conflictStyle = "zdiff3";
|
|
|
|
};
|
|
|
|
|
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;
|
|
|
|
};
|
2021-10-18 14:44:08 +02:00
|
|
|
|
|
|
|
url = {
|
2023-03-31 12:45:13 +02:00
|
|
|
"git@git.belanyi.fr:" = {
|
|
|
|
insteadOf = "https://git.belanyi.fr/";
|
2021-10-18 14:44:08 +02:00
|
|
|
};
|
2021-10-18 14:44:19 +02:00
|
|
|
|
|
|
|
"git@github.com:" = {
|
|
|
|
insteadOf = "https://github.com/";
|
|
|
|
};
|
2021-10-18 14:45:23 +02:00
|
|
|
|
|
|
|
"git@gitlab.com:" = {
|
|
|
|
insteadOf = "https://gitlab.com/";
|
|
|
|
};
|
2021-10-18 14:44:08 +02:00
|
|
|
};
|
2021-02-19 22:48:25 +01:00
|
|
|
};
|
2021-02-19 23:06:51 +01:00
|
|
|
|
|
|
|
# Multiple identities
|
|
|
|
includes = [
|
2021-10-12 21:11:46 +02:00
|
|
|
{
|
|
|
|
condition = "gitdir:~/git/EPITA/";
|
|
|
|
contents = {
|
|
|
|
user = {
|
|
|
|
name = "Bruno BELANYI";
|
|
|
|
email = mkMailAddress "bruno.belanyi" "epita.fr";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
2023-02-08 15:24:05 +01:00
|
|
|
{
|
|
|
|
condition = "gitdir:~/git/work/";
|
|
|
|
contents = {
|
|
|
|
user = {
|
|
|
|
name = "Bruno BELANYI";
|
|
|
|
email = mkMailAddress "ambroisie" "google.com";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
2021-02-19 23:06:51 +01:00
|
|
|
];
|
2021-02-19 23:16:22 +01:00
|
|
|
|
|
|
|
ignores =
|
|
|
|
let
|
2021-03-15 21:52:12 +01:00
|
|
|
inherit (builtins) readFile;
|
|
|
|
inherit (lib) filter hasPrefix splitString;
|
|
|
|
readLines = file: splitString "\n" (readFile file);
|
|
|
|
removeComments = filter (line: line != "" && !(hasPrefix "#" line));
|
2021-02-19 23:16:22 +01:00
|
|
|
getPaths = file: removeComments (readLines file);
|
|
|
|
in
|
|
|
|
getPaths ./default.ignore;
|
2021-02-19 22:48:25 +01:00
|
|
|
};
|
|
|
|
}
|