127 lines
2.6 KiB
Nix
127 lines
2.6 KiB
Nix
{ pkgs, userName, userEmail, gpgSigningKey, ... }:
|
|
|
|
{
|
|
programs = {
|
|
less.enable = true;
|
|
|
|
git = {
|
|
enable = true;
|
|
|
|
inherit userName;
|
|
inherit userEmail;
|
|
|
|
signing = {
|
|
key = gpgSigningKey;
|
|
signByDefault = true;
|
|
};
|
|
|
|
difftastic = {
|
|
enable = true;
|
|
background = "light";
|
|
};
|
|
|
|
lfs = {
|
|
enable = true;
|
|
};
|
|
|
|
extraConfig = {
|
|
core.editor = "nvim";
|
|
core.pager = "less -FX";
|
|
|
|
credential.helper = "cache --timeout=36000";
|
|
|
|
diff.ignoreSubmodules = "none";
|
|
|
|
fetch.parallel = 8;
|
|
fetch.writeCommitGraph = true;
|
|
fetch.recurseSubmodules = true;
|
|
|
|
format.pretty = "format:%C(yellow)%h %Cblue%>(12)%ad %C(red)%G? %Cgreen%<(7,trunc)%aN%Cred%d %Creset%s";
|
|
|
|
init.defaultBranch = "main";
|
|
|
|
log.date = "relative";
|
|
|
|
merge.ff = false;
|
|
merge.tool = "nvim";
|
|
|
|
mergetool.nvim.cmd = "nvim -f -c \"Gdiffsplit!\" \"$MERGED\"";
|
|
mergetool.prompt = false;
|
|
|
|
pager.difftool = true;
|
|
|
|
pull.rebase = true;
|
|
|
|
push.recurseSubmodules = "on-demand";
|
|
|
|
rebase.autostash = true;
|
|
|
|
rerere.enabled = true;
|
|
|
|
status.submoduleSummary = true;
|
|
|
|
submodule.fetchJobs = 8;
|
|
submodule.recurse = true;
|
|
|
|
worktree.guessRemote = true;
|
|
};
|
|
|
|
aliases = {
|
|
graph = "log --graph";
|
|
};
|
|
|
|
ignores = [
|
|
".env"
|
|
".direnv"
|
|
"*.swp"
|
|
];
|
|
};
|
|
};
|
|
|
|
home.packages = with pkgs; [
|
|
(writeShellScriptBin "git-clone-worktree" ''
|
|
|
|
uri=''${1}
|
|
dir=''${2}
|
|
|
|
if [[ -z ''${dir} ]]; then
|
|
dir=''$(basename ''${1} .git)
|
|
fi
|
|
|
|
if [[ -e ''${dir} ]]; then
|
|
echo "error: directory ''${dir} already exists"
|
|
exit 1
|
|
fi
|
|
|
|
mkdir ''${dir}
|
|
git clone ''${uri} ''${dir}/.base
|
|
|
|
branch=`git -C ''${dir}/.base symbolic-ref --short HEAD`
|
|
echo "default branch is ''${branch}"
|
|
|
|
git -C ''${dir}/.base checkout --detach HEAD
|
|
git -C ''${dir}/.base worktree add ../''${branch}
|
|
'')
|
|
|
|
(writeShellScriptBin "git-make-relative" ''
|
|
|
|
gitfile=''${1}
|
|
|
|
if [[ -z ''${gitfile} ]]; then
|
|
gitfile=".git"
|
|
fi
|
|
|
|
if [[ ! -f ''${gitfile} ]]; then
|
|
echo "file ''${gitfile} does not exist"
|
|
exit 1
|
|
fi
|
|
|
|
gitdir=$(grep "gitdir:" ''${gitfile} | cut -d: -f2 | xargs)
|
|
rel_gitdir=$(realpath -s --relative-to=. ''${gitdir})
|
|
|
|
echo "relative path: ''${rel_gitdir}"
|
|
|
|
sed -i -e "s,gitdir:.*,gitdir: ''${rel_gitdir}," ''${gitfile}
|
|
'')
|
|
];
|
|
}
|