nichts/modules/programs/cli/jj.mod.nix

140 lines
2.7 KiB
Nix
Raw Permalink Normal View History

2025-05-22 20:01:01 +02:00
{
config,
lib,
pkgs,
...
}:
let
2025-05-22 20:01:01 +02:00
inherit (lib.meta) getExe;
toml = pkgs.formats.toml { };
2025-05-22 20:01:01 +02:00
jj-config = toml.generate "config.toml" {
user = {
name = "Bloxx12";
email = "charlie@charlieroot.dev";
};
ui = {
pager = [
"${getExe pkgs.bat}"
"--plain"
];
2025-05-22 20:01:01 +02:00
default-command = "log";
movement.edit = true;
diff.tool = [
"${getExe pkgs.difftastic}"
"--color"
"always"
"$left"
"$right"
];
2025-05-22 20:01:01 +02:00
};
# FIXME: do this with agenix
# "--scope" = [
# {
# "--when.repositories" = ["~/repos/projects/uni"];
# user = {
# # TODO
# name = "";
# email = "";
# };
# }
# {
# "--when.repositories" = ["~/repos/projects/uni/"];
# user = {
# # TODO
# name = "";
# email = "";
# };
# }
# ];
git.push-new-bookmarks = true;
signing = {
behaviour = "own";
backend = "ssh";
key = [
"ecdsa-sha2-nistp521 AAAAE2VjZHNhLXNoYTItbmlzdHA1MjEAAAAIbmlzdHA1MjEAAACFBAAWEDj/Yib6Mqs016jx7rtecWpytwfVl28eoHtPYCM9TVLq81VIHJSN37lbkc/JjiXCdIJy2Ta3A3CVV5k3Z37NbgAu23oKA2OcHQNaRTLtqWlcBf9fk9suOkP1A3NzAqzivFpBnZm3ytaXwU8LBJqxOtNqZcFVruO6fZxJtg2uE34mAw=="
];
2025-05-22 20:01:01 +02:00
};
aliases = {
c = [ "commit" ];
ci = [
"commit"
"--interactive"
];
2025-05-22 20:01:01 +02:00
e = [ "edit" ];
2025-05-22 20:01:01 +02:00
# "new bookmark"
nb = [
"bookmark"
"create"
"-r @-"
];
2025-05-22 20:01:01 +02:00
pull = [
"git"
"fetch"
];
push = [
"git"
"push"
"--allow-new"
];
2025-05-22 20:01:01 +02:00
r = [ "rebase" ];
s = [ "squash" ];
si = [
"squash"
"--interactive"
];
2025-05-22 20:01:01 +02:00
tug = [
"bookmark"
"move"
"--from"
"closest_bookmark(@-)"
"--to"
"@-"
];
2025-05-22 20:01:01 +02:00
};
revset-aliases = {
"closest_bookmark(to)" = "heads(::to & bookmarks())";
};
templates = {
draft_commit_description = ''
concat(
coalesce(description, "\n"),
surround(
"\nJJ: This commit contains the following changes:\n", "",
indent("JJ: ", diff.stat(72)),
),
"\nJJ: ignore-rest\n",
diff.git(),
)
'';
};
template-aliases = {
"format_short_id(id)" = "id.shortest()";
};
};
jj-wrapped = pkgs.symlinkJoin {
name = "jj-wrapped";
paths = [ pkgs.jj ];
nativeBuildInputs = [ pkgs.makeWrapper ];
2025-05-22 20:01:01 +02:00
postBuild = ''
wrapProgram $out/bin/mako --add-flags "\
--config ${jj-config}
'';
};
in
{
2025-05-26 10:00:02 +02:00
# environment.systemPackages = [jj-wrapped];
2025-05-22 20:01:01 +02:00
}