/nix/store/dlwqlnbaj5vfm9aw20r1yxk8y56lmgif-repo/header.tmpl
nichts/modules/programs/cli/jujutsu.mod.nix
2025-09-08 20:02:55 +02:00

132 lines
2.9 KiB
Nix

{
config,
lib,
pkgs,
self,
...
}:
let
inherit (lib.meta) getExe;
inherit (lib.lists) singleton;
inherit (lib.modules) mkIf;
inherit (config.meta.mainUser) username;
inherit (config.meta.system) isWorkstation;
toml = pkgs.formats.toml { };
jj-config = toml.generate "config.toml" {
user = {
email = "fau@faukah.com";
name = "faukah";
};
aliases = {
c = [ "commit" ];
ci = [
"commit"
"--interactive"
];
e = [ "edit" ];
i = [
"git"
"init"
"--colocate"
];
nb = [
"bookmark"
"create"
"-r @-"
];
pull = [
"git"
"fetch"
];
push = [
"git"
"push"
"--allow-new"
];
r = [ "rebase" ];
s = [ "squash" ];
si = [
"squash"
"--interactive"
];
tug = [
"bookmark"
"move"
"--from"
"closest_bookmark(@-)"
"--to"
"@-"
];
};
git = {
# colocate = true;
push-new-bookmarks = true;
};
revset-aliases."closest_bookmark(to)" = "heads(::to & bookmarks())";
signing = {
backend = "ssh";
behavior = "drop";
key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILPiRe9OH/VtWFWyy5QbAVcN7CLxr4zUtRCwmxD6aeN6";
};
template-aliases = {
"format_short_id(id)" = "id.shortest()";
"format_timestamp(timestamp)" = "timestamp.ago()";
};
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(),
)
'';
};
ui = {
default-command = "log";
diff-editor = ":builtin";
diff-formatter = [
"${getExe pkgs.difftastic}"
"--color"
"always"
"$left"
"$right"
];
movement = {
edit = true;
};
pager = [
"${getExe pkgs.bat}"
"--plain"
];
};
};
inherit (config.age.secrets) organizationScope uniScope;
jj-wrapped = pkgs.symlinkJoin {
name = "jj-wrapped";
paths = singleton [ pkgs.jujutsu ];
nativeBuildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/jj --add-flags " --config-file ${organizationScope.path} --config-file ${uniScope.path}"
'';
};
in
{
hjem.users.${username}.xdg.config.files."jj/config.toml".source = jj-config;
age.secrets.organizationScope = mkIf isWorkstation {
file = "${self}/secrets/organization_scope.age";
owner = username;
};
age.secrets.uniScope = mkIf isWorkstation {
file = "${self}/secrets/uni_scope.age";
owner = username;
};
environment.systemPackages = singleton (if isWorkstation then jj-wrapped else pkgs.jujutsu);
}