nix-dotfiles/home/programs/git/default.nix

169 lines
4.2 KiB
Nix
Raw Normal View History

{ config, pkgs, lib, ... }:
let
cfg = config.programs.git;
in
2022-03-07 16:01:52 +01:00
{
programs.git = {
enable = true;
package = pkgs.gitFull;
userName = "h7x4";
2022-08-18 23:17:01 +02:00
userEmail = "h7x4@nani.wtf";
signing = {
key = "46B9228E814A2AAC";
signByDefault = true;
};
2022-03-07 16:01:52 +01:00
2024-06-25 19:03:17 +02:00
lfs.enable = true;
delta = {
enable = true;
options = {
line-numbers = true;
side-by-side = true;
theme = "Monokai Extended Origin";
};
};
2022-03-07 16:01:52 +01:00
aliases = {
2024-06-02 16:24:39 +02:00
aliases = "!git config --get-regexp alias | sed -re 's/alias\\.(\\S*)\\s(.*)$/\\1 = \\2/g'";
delete-merged = "!git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d";
graph = "log --graph --abbrev-commit --decorate --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";
graphv = "log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all";
forcepush = "push --force-with-lease --force-if-includes";
authors = "shortlog --summary --numbered --email";
si = "switch-interactive";
rebase-author = "rebase -i -x \"git commit --amend --reset-author -CHEAD\"";
2022-03-07 16:01:52 +01:00
};
extraConfig = {
core = {
whitespace = "space-before-tab,-indent-with-non-tab,trailing-space";
untrackedCache = true;
editor = "nvim";
};
2024-07-03 23:10:51 +02:00
safe.directory = "*";
2024-06-02 16:24:39 +02:00
rerere.enabled = true;
branch.sort = "-committerdate";
2022-03-07 16:01:52 +01:00
"color \"branch\"".upstream = "cyan";
color.ui = "auto";
init.defaultBranch = "main";
2024-07-03 23:10:51 +02:00
fetch = {
prune = true;
fsckObjects = true;
};
transfer.fsckObjects = true;
receive.fsckObjects = true;
2022-03-07 16:01:52 +01:00
pull.rebase = true;
2024-07-03 23:10:51 +02:00
rebase = {
autoStash = true;
autoSquash = true;
abbreviateCommands = true;
updateRefs = true;
};
push = {
default = "current";
autoSetupRemote = true;
followTags = true;
};
2022-03-07 16:01:52 +01:00
merge = {
tool = "nvimdiff";
conflictstyle = "diff3";
colorMoved = "zebra";
};
mergetool.keepBackup = false;
"mergetool \"nvimdiff\"".cmd = "nvim -d $BASE $LOCAL $REMOTE $MERGED -c '$wincmd w' -c 'wincmd J'";
diff = {
mnemonicPrefix = true;
renames = true;
tool = "nvimdiff";
2024-07-03 23:10:51 +02:00
submodule = "log";
};
status = {
showUntrackedFiles = "all";
relativePaths = true;
submoduleSummary = true;
2022-03-07 16:01:52 +01:00
};
2024-07-03 23:10:51 +02:00
log.date = "iso";
submodule.recurse = true;
2022-03-07 16:01:52 +01:00
grep = {
break = true;
heading= true;
lineNumber = true;
extendedRegexp = true;
};
2024-07-03 23:10:51 +02:00
# Run autocorrected command after 3 seconds
help.autocorrect = "30";
2022-03-07 16:01:52 +01:00
2024-07-03 23:10:51 +02:00
github.user = "h7x4";
2024-07-03 23:10:51 +02:00
"url \"github:\"".insteadOf = [
"https://github.com/"
"ssh://git@github.com:"
"git@github.com:"
"github.com:"
];
"url \"pvv-git:\"".insteadOf = [
"https://git.pvv.org/"
"ssh://gitea@git.pvv.ntnu.no:2222/"
"gitea@git.pvv.ntnu.no:2222/"
"gitea@git.pvv.ntnu.no:"
"git.pvv.ntnu.no:"
];
2024-06-02 16:24:39 +02:00
2022-03-07 16:01:52 +01:00
web.browser = "google-chrome-stable";
"filter \"lfs\"" = {
required = true;
smudge = "git-lfs smudge -- %f";
process = "git-lfs filter-process";
clean = "git-lfs clean -- %f";
};
};
ignores = [
".vscode"
".direnv"
".envrc"
"shell.nix"
];
2022-03-07 16:01:52 +01:00
};
home.packages = [
(pkgs.writeShellApplication {
name = "git-tcommit";
runtimeInputs = with pkgs; [ cfg.package coreutils ];
text = lib.fileContents ./scripts/git-tcommit.sh;
})
(pkgs.writeShellApplication {
name = "git-switch-interactive";
runtimeInputs = with pkgs; [ cfg.package fzf gnused coreutils ];
text = lib.fileContents ./scripts/git-switch-interactive.sh;
excludeShellChecks = [
"SC2001" # (style): See if you can use ${variable//search/replace} instead. (sed invocation)
];
})
];
2022-03-07 16:01:52 +01:00
}