1
0
Fork 0
dotfiles/home/programs/git.nix

222 lines
4.5 KiB
Nix
Raw Permalink Normal View History

{ pkgs, config, lib, ... }:
2021-12-30 21:33:41 +00:00
let
inherit (lib) mkIf;
inherit (pkgs.stdenv.hostPlatform) isDarwin;
in
2021-12-06 22:35:29 +00:00
{
2023-01-28 19:17:25 +00:00
home.packages = with pkgs; [
git-absorb
git-crypt
];
2022-07-30 20:44:28 +00:00
2021-12-06 22:35:29 +00:00
programs.git = {
enable = true;
lfs.enable = true;
2022-04-05 20:03:38 +00:00
difftastic = {
enable = true;
};
2021-12-06 22:35:29 +00:00
userName = "Daniel Kempkens";
userEmail = "daniel+git@kempkens.io";
aliases = {
2024-04-12 20:13:16 +00:00
pushf = "push --force-with-lease --force-if-includes";
2024-04-13 11:28:21 +00:00
commend = "commit --amend --no-edit";
commedit = "commit --amend";
graph = "log --graph --all --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(bold white) %an%C(reset)%C(bold yellow)%d%C(reset)' --abbrev-commit --date=relative";
rbi = "rebase --interactive --autosquash --autostash";
rbc = "rebase --continue";
rbabort = "rebase --abort";
2021-12-06 22:35:29 +00:00
};
extraConfig = {
core = {
editor = "nvim";
whitespace = "trailing-space,space-before-tab";
autocrlf = "input";
};
pull = {
rebase = true;
};
push = {
default = "simple";
};
2024-04-13 11:28:21 +00:00
branch = {
sort = "-committerdate";
2021-12-06 22:35:29 +00:00
};
2023-11-07 11:36:04 +00:00
merge = {
conflictStyle = "zdiff3";
};
2024-04-12 20:13:16 +00:00
rebase = {
updateRefs = true;
};
2021-12-06 22:35:29 +00:00
rerere = {
enabled = true;
};
2024-04-13 11:28:21 +00:00
init = {
defaultBranch = "master";
2024-04-12 20:13:16 +00:00
};
2021-12-06 22:35:29 +00:00
color = {
ui = "auto";
};
2024-04-12 20:13:16 +00:00
column = {
ui = "auto";
};
2024-04-13 11:28:21 +00:00
apply = {
whitespace = "fix";
};
maintenance = mkIf isDarwin {
strategy = "incremental";
repo = let home = config.home.homeDirectory; in [
"${home}/.config/nixpkgs"
];
};
2021-12-06 22:35:29 +00:00
};
ignores = [
"*~"
"*.swp"
2022-01-10 11:28:37 +00:00
".direnv/"
2021-12-06 22:35:29 +00:00
".DS_Store"
];
2021-12-30 21:33:41 +00:00
includes = [
# Maintenance
(mkIf isDarwin {
path = "${config.xdg.configHome}/git/maintenance-config";
})
2022-08-23 21:33:04 +00:00
# Private
2023-09-11 22:05:25 +00:00
{
2023-10-02 17:25:16 +00:00
condition = "hasconfig:remote.*.url:forgejo@git.kempkens.io:*/**";
2023-09-11 22:05:25 +00:00
contents = {
user = {
signingKey = "~/.ssh/GitHub.pub";
};
commit = {
gpgSign = true;
};
tag = {
gpgSign = true;
};
gpg = {
format = "ssh";
};
};
}
2021-12-30 21:33:41 +00:00
{
2022-08-23 21:33:04 +00:00
condition = "hasconfig:remote.*.url:git@github.com:*/**";
contents = {
user = {
signingKey = "~/.ssh/GitHub.pub";
};
commit = {
gpgSign = true;
};
tag = {
gpgSign = true;
};
gpg = {
format = "ssh";
};
};
2021-12-30 21:33:41 +00:00
}
2022-01-01 00:06:30 +00:00
2022-08-23 21:33:04 +00:00
# Work
2022-01-01 00:06:30 +00:00
{
2022-08-23 21:33:04 +00:00
condition = "hasconfig:remote.*.url:git@git.app.nedeco.de:*/**";
contents = {
user = {
email = "d.kempkens@nedeco.de";
name = "Daniel Kempkens";
signingKey = "~/.ssh/nedeco_gitlab.pub";
};
commit = {
gpgSign = true;
};
tag = {
gpgSign = true;
};
gpg = {
format = "ssh";
};
"gpg \"ssh\"" = {
allowedSignersFile = "~/.ssh/allowed_signers/work-nedeco";
};
};
2022-01-01 00:06:30 +00:00
}
2021-12-30 21:33:41 +00:00
];
2021-12-06 22:35:29 +00:00
};
2021-12-30 21:33:41 +00:00
2022-04-14 14:39:13 +00:00
home.sessionVariables.GIT_CEILING_DIRECTORIES = "/Users";
launchd.agents = mkIf isDarwin (
let
gitExecPath = "${config.programs.git.package}/libexec/git-core";
git = "${gitExecPath}/git";
calendarInterval = schedule:
let
freq = {
"hourly" = [{ Minute = 0; }];
"daily" = [{
Hour = 0;
Minute = 0;
}];
"weekly" = [{
Weekday = 1;
Hour = 0;
Minute = 0;
}];
};
in
freq.${schedule};
launchdAgent = { schedule }: {
enable = true;
config = {
ProgramArguments = [
git
"--exec-path=${gitExecPath}"
"for-each-repo"
"--config=maintenance.repo"
"maintenance"
"run"
"--schedule=${schedule}"
];
StartCalendarInterval = calendarInterval schedule;
};
};
in
{
git-maintenance-hourly = launchdAgent { schedule = "hourly"; };
git-maintenance-daily = launchdAgent { schedule = "daily"; };
git-maintenance-weekly = launchdAgent { schedule = "weekly"; };
}
);
2021-12-06 22:35:29 +00:00
}