nix/home/programs/git.nix

41 lines
935 B
Nix

{pkgs, ...}: {
programs.git = {
enable = true;
aliases = {
graph = "log --oneline --all --graph";
amend = "commit --amend --no-edit";
sdiff = "diff --staged";
fpush = "push --force-with-lease";
t = "tag --annotate";
bclone = "!sh ${pkgs.writeShellScriptBin "bare-clone" ''
url=$1
basename=''${url##*/}
if [[ $2 == -* ]]
then
opts=''${@:2}
name=''${basename%.*}
else
opts=''${@:3}
name=''${2:-''${basename%.*}}
fi
mkdir "$name"
git clone --bare "$url" "$name/.bare" $opts || {
rm -r "$name"
exit 1
}
cd "$name"
echo "gitdir: ./.bare" > .git
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
git fetch origin $opts
''}/bin/bare-clone";
};
difftastic = {
enable = true;
};
};
}