nix/home-manager/shared/programs/shell/git.nix
iofq 8694c7d81f
All checks were successful
/ check (push) Successful in 3m6s
jj changes
2026-02-16 00:48:38 -06:00

131 lines
3.3 KiB
Nix
Executable file

{ pkgs, config, ... }:
{
programs.git = {
enable = true;
settings = {
user = {
email = "cjriddz@protonmail.com";
name = "iofq";
};
core.editor = "nvim";
pull.rebase = true;
difftool."nvim_difftool" = {
cmd = ''nvim -c "packadd nvim.difftool" -c "DiffTool $LOCAL $REMOTE"'';
};
diff = {
tool = "nvim_difftool";
};
};
signing = {
key = "cjriddz@protonmail.com";
signByDefault = false;
};
};
programs.delta = {
enable = true;
options = {
side-by-side = true;
line-numbers = true;
};
};
# home.packages = [ pkgs.watchman ];
programs.jujutsu = {
enable = true;
settings = {
# core = {
# fsmonitor = "watchman";
# watchman = {
# register-snapshot-trigger = true;
# };
# };
user = {
email = "cjriddz@protonmail.com";
name = "iofq";
};
operation = {
username = "iofq";
};
signing = {
behavior = "drop";
backend = "gpg";
key = "cjriddz@protonmail.com";
};
ui = {
default-command = [ "log" ];
conflict-marker-style = "git";
merge-editor = "vimdiff";
diff-editor = "difftool";
diff-instructions = false;
diff-formatter = ":git";
movement = {
edit = true;
};
};
merge-tools.vimdiff = {
program = "nvim";
};
merge-tools.difftool =
let
cmd = [
"-c"
''
ARGS="lua require('difftool').open('$left', '$right', {ignore = { '.git', '.jj' }})"
git -C "$left" init -q
git -C "$left" add -A
git -C "$left" commit -q -m baseline --allow-empty
mv "$left/.git" "$right"
git -C "$right" add --intent-to-add -A
if [ -z "$NVIM" ]; then
vim -c "$ARGS"
else
vim \
--server $NVIM \
--remote-send "<cmd>$ARGS<cr>"
until vim \
--headless \
--server "$NVIM" \
--remote-expr "v:lua.require'iofq.jj'.is_jj_diffedit_open()" 2>/dev/null | grep 0; do
sleep 1
done
fi
git -C "$right" diff-index --quiet --cached HEAD && { echo "No changes done, aborting split."; exit 1; }
git -C "$right" commit -q -m split
git -C "$right" restore . # undo changes in modified files
git -C "$right" reset . # undo --intent-to-add
git -C "$right" clean -q -df # remove untracked files
''
];
in
{
program = "sh";
edit-args = cmd;
diff-args = cmd;
};
snapshot = {
max-new-file-size = "10MiB";
};
revsets = {
anc = "ancestors(@,10) | trunk()";
};
aliases = {
tug = [
"bookmark"
"move"
"--from"
"heads(::@- & bookmarks())"
"--to"
"@"
];
};
fix = {
tools = {
treefmt = {
command = [ "treefmt" ];
patterns = [ "glob:**/*.nix" ];
};
};
};
};
};
}