refactor: extract git config
This commit is contained in:
parent
7b8e76860c
commit
92369cc90b
5 changed files with 6 additions and 75 deletions
126
horsch/git.nix
126
horsch/git.nix
|
@ -1,126 +0,0 @@
|
|||
{ pkgs, userName, userEmail, ... }:
|
||||
|
||||
{
|
||||
programs = {
|
||||
less.enable = true;
|
||||
|
||||
git = {
|
||||
enable = true;
|
||||
|
||||
inherit userName;
|
||||
inherit userEmail;
|
||||
|
||||
signing = {
|
||||
key = "088ED38F036C7AF2";
|
||||
signByDefault = true;
|
||||
};
|
||||
|
||||
difftastic = {
|
||||
enable = true;
|
||||
background = "light";
|
||||
};
|
||||
|
||||
lfs = {
|
||||
enable = true;
|
||||
};
|
||||
|
||||
extraConfig = {
|
||||
core.editor = "nvim";
|
||||
core.pager = "less -FX";
|
||||
|
||||
credential.helper = "cache --timeout=3600";
|
||||
|
||||
diff.ignoreSubmodules = "none";
|
||||
|
||||
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.recurse = true;
|
||||
|
||||
worktree.guessRemote = true;
|
||||
};
|
||||
|
||||
aliases = {
|
||||
graph = "log --graph --all --max-count 32";
|
||||
};
|
||||
|
||||
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}
|
||||
'')
|
||||
];
|
||||
}
|
||||
|
|
@ -26,7 +26,7 @@
|
|||
../ripgrep.nix
|
||||
../starship.nix
|
||||
../zoxide.nix
|
||||
./git.nix
|
||||
../git.nix
|
||||
./gpg
|
||||
./neovim
|
||||
./picocom.nix
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue