2024-07-03 23:35:52 +02:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.programs.git;
|
2024-07-08 15:32:00 +02:00
|
|
|
|
|
|
|
github-uri-prefixes = [
|
|
|
|
# Preferred
|
|
|
|
"github:"
|
|
|
|
|
|
|
|
# Alternative
|
|
|
|
"https://github.com/"
|
|
|
|
"ssh://git@github.com:"
|
|
|
|
"git@github.com:"
|
|
|
|
"github.com:"
|
|
|
|
];
|
2024-07-03 23:35:52 +02:00
|
|
|
in
|
2022-03-07 16:01:52 +01:00
|
|
|
{
|
2024-08-09 15:21:34 +02:00
|
|
|
imports = [
|
|
|
|
./maintenance-timers.nix
|
|
|
|
];
|
|
|
|
|
2024-07-08 15:32:00 +02:00
|
|
|
# TODO: convert to template once nix-sops supports it in hm module
|
|
|
|
sops.secrets."git/nordicsemi-config" = { };
|
2022-03-07 16:01:52 +01:00
|
|
|
|
2024-07-08 15:32:00 +02:00
|
|
|
programs.git = lib.mkMerge [
|
|
|
|
{
|
|
|
|
enable = true;
|
|
|
|
package = pkgs.gitFull;
|
2022-08-18 23:17:01 +02:00
|
|
|
|
2024-07-08 15:32:00 +02:00
|
|
|
userName = "h7x4";
|
|
|
|
userEmail = "h7x4@nani.wtf";
|
2022-03-07 16:01:52 +01:00
|
|
|
|
2024-07-08 15:32:00 +02:00
|
|
|
signing = {
|
|
|
|
key = "46B9228E814A2AAC";
|
|
|
|
signByDefault = true;
|
|
|
|
};
|
2024-06-25 19:03:17 +02:00
|
|
|
|
2024-07-08 15:32:00 +02:00
|
|
|
lfs.enable = true;
|
|
|
|
|
|
|
|
delta = {
|
|
|
|
enable = true;
|
|
|
|
options = {
|
|
|
|
line-numbers = true;
|
|
|
|
side-by-side = true;
|
|
|
|
theme = "Monokai Extended Origin";
|
|
|
|
};
|
2022-11-11 21:23:25 +01:00
|
|
|
};
|
2024-07-08 15:32:00 +02:00
|
|
|
|
|
|
|
aliases = {
|
|
|
|
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";
|
2024-10-04 16:32:07 +02:00
|
|
|
subs = "submodule update --init --recursive";
|
2024-07-08 15:32:00 +02:00
|
|
|
rebase-author = "rebase -i -x \"git commit --amend --reset-author -CHEAD\"";
|
2024-08-09 15:23:58 +02:00
|
|
|
git = "!git";
|
2022-03-07 16:01:52 +01:00
|
|
|
};
|
|
|
|
|
2024-07-08 15:32:00 +02: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
|
|
|
|
2024-07-08 15:32:00 +02:00
|
|
|
safe.directory = "*";
|
2024-06-02 16:24:39 +02:00
|
|
|
|
2024-08-02 17:44:27 +02:00
|
|
|
interactive.singleKey = true;
|
|
|
|
|
|
|
|
advice.detachedHead = false;
|
|
|
|
|
2024-07-08 15:32:00 +02:00
|
|
|
rerere.enabled = true;
|
2024-06-02 16:24:39 +02:00
|
|
|
|
2024-08-02 17:44:27 +02:00
|
|
|
branch = {
|
|
|
|
sort = "-committerdate";
|
|
|
|
autoSetupRebase = "always";
|
|
|
|
};
|
2022-03-07 16:01:52 +01:00
|
|
|
|
2024-07-08 15:32:00 +02:00
|
|
|
"color \"branch\"".upstream = "cyan";
|
|
|
|
color.ui = "auto";
|
2024-07-03 23:10:51 +02:00
|
|
|
|
2024-07-08 15:32:00 +02:00
|
|
|
init.defaultBranch = "main";
|
2024-07-03 23:10:51 +02:00
|
|
|
|
2024-07-08 15:32:00 +02:00
|
|
|
fetch = {
|
|
|
|
prune = true;
|
|
|
|
fsckObjects = true;
|
|
|
|
};
|
2024-07-03 23:10:51 +02:00
|
|
|
|
2024-08-05 14:09:48 +02:00
|
|
|
maintenance.strategy = "incremental";
|
|
|
|
|
2024-08-09 15:21:34 +02:00
|
|
|
scalar = {
|
|
|
|
repo = [ "${config.home.homeDirectory}/nixpkgs" ];
|
|
|
|
};
|
|
|
|
|
2024-07-08 15:32:00 +02:00
|
|
|
transfer.fsckObjects = true;
|
2024-07-03 23:10:51 +02:00
|
|
|
|
2024-07-08 15:32:00 +02:00
|
|
|
receive.fsckObjects = true;
|
2023-02-25 17:55:35 +01:00
|
|
|
|
2024-07-08 15:32:00 +02:00
|
|
|
pull.rebase = true;
|
2024-07-03 23:10:51 +02:00
|
|
|
|
2024-07-08 15:32:00 +02:00
|
|
|
rebase = {
|
|
|
|
autoStash = true;
|
|
|
|
autoSquash = true;
|
|
|
|
abbreviateCommands = true;
|
|
|
|
updateRefs = true;
|
|
|
|
};
|
2022-03-07 16:01:52 +01:00
|
|
|
|
2024-07-08 15:32:00 +02:00
|
|
|
push = {
|
|
|
|
default = "current";
|
|
|
|
autoSetupRemote = true;
|
|
|
|
followTags = true;
|
|
|
|
};
|
2022-03-07 16:01:52 +01:00
|
|
|
|
2024-07-08 15:32:00 +02:00
|
|
|
merge = {
|
|
|
|
tool = "nvimdiff";
|
|
|
|
conflictstyle = "diff3";
|
|
|
|
colorMoved = "zebra";
|
|
|
|
};
|
2022-03-07 16:01:52 +01:00
|
|
|
|
2024-07-08 15:32:00 +02:00
|
|
|
mergetool.keepBackup = false;
|
|
|
|
"mergetool \"nvimdiff\"".cmd = "nvim -d $BASE $LOCAL $REMOTE $MERGED -c '$wincmd w' -c 'wincmd J'";
|
2024-07-03 23:10:51 +02:00
|
|
|
|
2024-07-08 15:32:00 +02:00
|
|
|
diff = {
|
|
|
|
mnemonicPrefix = true;
|
|
|
|
renames = true;
|
|
|
|
tool = "nvimdiff";
|
|
|
|
submodule = "log";
|
|
|
|
};
|
2022-03-07 16:01:52 +01:00
|
|
|
|
2024-10-02 12:31:10 +02:00
|
|
|
pager.show = lib.getExe pkgs.bat;
|
|
|
|
|
2024-07-08 15:32:00 +02:00
|
|
|
status = {
|
|
|
|
showUntrackedFiles = "all";
|
|
|
|
relativePaths = true;
|
|
|
|
submoduleSummary = true;
|
|
|
|
};
|
2024-07-03 23:10:51 +02:00
|
|
|
|
2024-07-08 15:32:00 +02:00
|
|
|
log.date = "iso";
|
2024-07-03 23:10:51 +02:00
|
|
|
|
2024-07-08 15:32:00 +02:00
|
|
|
submodule.recurse = true;
|
|
|
|
|
|
|
|
grep = {
|
|
|
|
break = true;
|
|
|
|
heading= true;
|
|
|
|
lineNumber = true;
|
|
|
|
extendedRegexp = true;
|
|
|
|
};
|
|
|
|
|
2024-08-02 17:44:27 +02:00
|
|
|
"notes \"rewrite\"" = {
|
|
|
|
amend = true;
|
|
|
|
rebase = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
versionsort = {
|
|
|
|
prereleaseSuffix = lib.mapCartesianProduct ({ binding, suffix }: "${binding}${suffix}") {
|
|
|
|
binding = [ "-" "." "/" ];
|
|
|
|
suffix = [ "pre" "alpha" "beta" "rc" ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-07-08 15:32:00 +02:00
|
|
|
# Run autocorrected command after 3 seconds
|
|
|
|
help.autocorrect = "30";
|
|
|
|
|
|
|
|
github.user = "h7x4";
|
2022-03-07 16:01:52 +01:00
|
|
|
|
2024-07-08 15:32:00 +02:00
|
|
|
"url \"${lib.head github-uri-prefixes}\"".insteadOf = lib.tail github-uri-prefixes;
|
2022-03-07 16:01:52 +01:00
|
|
|
|
2024-07-08 15:32:00 +02:00
|
|
|
web.browser = "google-chrome-stable";
|
2024-06-25 20:13:30 +02:00
|
|
|
|
2024-07-08 15:32:00 +02:00
|
|
|
"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"
|
2024-07-03 23:10:51 +02:00
|
|
|
];
|
2024-07-08 15:32:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
(let
|
|
|
|
uri-prefixes = [
|
|
|
|
# Preferred
|
|
|
|
"pvv-git:"
|
2024-07-03 23:10:51 +02:00
|
|
|
|
2024-07-08 15:32:00 +02:00
|
|
|
# Alternative
|
2024-07-03 23:10:51 +02:00
|
|
|
"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
|
|
|
|
2024-07-08 15:32:00 +02:00
|
|
|
prefixes-per-org = let
|
|
|
|
organizations = [
|
|
|
|
"Drift"
|
|
|
|
"Projects"
|
|
|
|
];
|
|
|
|
in lib.genAttrs organizations (org: map (uri-prefix: "${uri-prefix}${org}") uri-prefixes);
|
|
|
|
in {
|
|
|
|
extraConfig."url \"${lib.head uri-prefixes}\"".insteadOf = lib.tail uri-prefixes;
|
|
|
|
|
|
|
|
includes = map (x: {
|
|
|
|
contentSuffix = "pvv.gitconfig";
|
|
|
|
condition = "hasconfig:remote.*.url:${x}**";
|
|
|
|
contents = {
|
|
|
|
user = {
|
|
|
|
email = "oysteikt@pvv.ntnu.no";
|
|
|
|
name = "Øystein Tveit";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}) (lib.flatten (lib.attrValues prefixes-per-org));
|
|
|
|
})
|
2022-03-07 16:01:52 +01:00
|
|
|
|
2024-07-08 15:32:00 +02:00
|
|
|
(let
|
|
|
|
bitbucket-uri-prefixes = [
|
|
|
|
# Preferred
|
|
|
|
"bitbucket-nordicsemi:"
|
|
|
|
|
|
|
|
# Alternative
|
|
|
|
"ssh://git@bitbucket.nordicsemi.no:7999"
|
|
|
|
"https://projecttools.nordicsemi.no/bitbucket/scm"
|
|
|
|
];
|
|
|
|
|
|
|
|
prefixes-per-org = let
|
|
|
|
organizations = [
|
|
|
|
"NordicSemiconductor"
|
|
|
|
"NordicPlayground"
|
|
|
|
"nrfconnect"
|
2024-08-02 17:44:27 +02:00
|
|
|
"oysteintveit-nordicsemi"
|
2024-07-08 15:32:00 +02:00
|
|
|
];
|
|
|
|
in lib.genAttrs organizations (org: map (uri-prefix: "${uri-prefix}${org}") github-uri-prefixes);
|
|
|
|
in {
|
|
|
|
extraConfig = lib.mergeAttrs
|
|
|
|
{
|
|
|
|
"url \"${lib.head bitbucket-uri-prefixes}\"".insteadOf = lib.tail bitbucket-uri-prefixes;
|
|
|
|
}
|
|
|
|
(lib.mapAttrs' (org: uri-prefixes: {
|
|
|
|
name = "url \"github-nordicsemi:${org}\"";
|
|
|
|
value.insteadOf = uri-prefixes;
|
|
|
|
}) prefixes-per-org)
|
|
|
|
;
|
|
|
|
|
|
|
|
includes = map (x: {
|
|
|
|
contentSuffix = "nordicsemi.gitconfig";
|
|
|
|
condition = "hasconfig:remote.*.url:${x}/**";
|
|
|
|
path = config.sops.secrets."git/nordicsemi-config".path;
|
|
|
|
}) (bitbucket-uri-prefixes ++ (lib.flatten (lib.attrValues prefixes-per-org)));
|
|
|
|
})
|
|
|
|
];
|
2024-07-03 23:35:52 +02:00
|
|
|
|
|
|
|
home.packages = [
|
|
|
|
(pkgs.writeShellApplication {
|
|
|
|
name = "git-tcommit";
|
|
|
|
runtimeInputs = with pkgs; [ cfg.package coreutils ];
|
|
|
|
text = lib.fileContents ./scripts/git-tcommit.sh;
|
|
|
|
})
|
2024-10-05 12:07:34 +02:00
|
|
|
(pkgs.writeShellApplication {
|
|
|
|
name = "git-tmcommit";
|
|
|
|
runtimeInputs = with pkgs; [ cfg.package coreutils ];
|
|
|
|
text = lib.pipe ./scripts/git-tcommit.sh [
|
|
|
|
lib.fileContents
|
|
|
|
(builtins.replaceStrings ["hours" "tcommit"] ["minutes" "tmcommit"])
|
|
|
|
];
|
|
|
|
})
|
2024-07-03 23:35:52 +02:00
|
|
|
(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)
|
|
|
|
];
|
|
|
|
})
|
2024-08-02 17:44:27 +02:00
|
|
|
|
|
|
|
pkgs.git-absorb
|
2024-07-03 23:35:52 +02:00
|
|
|
];
|
2022-03-07 16:01:52 +01:00
|
|
|
}
|