nixos/home/modules/programs/jujutsu.nix

119 lines
3.3 KiB
Nix

{
pkgs,
config,
lib,
...
}: let
cfg = config.youthlic.programs.jujutsu;
in {
options = {
youthlic.programs.jujutsu = {
enable = lib.mkEnableOption "jujutsu";
email = lib.mkOption {
type = lib.types.str;
description = ''
jujutsu email
'';
};
signKey = lib.mkOption {
type = lib.types.addCheck (lib.types.nullOr lib.types.str) (
x: (x == null || config.youthlic.programs.gpg.enable)
);
default = null;
description = ''
key fingerprint for sign commit
'';
};
name = lib.mkOption {
type = lib.types.str;
example = ''youthlic'';
description = ''
jujutsu name
'';
};
};
};
config = lib.mkMerge [
(lib.mkIf cfg.enable {
home.packages = with pkgs; [
watchman
];
programs.jujutsu = {
enable = true;
settings = {
"$schema" = "https://jj-vcs.github.io/jj/latest/config-schema.json";
aliases = {
dlog = ["log" "-r"];
l = ["log" "-r" "(trunk()..@):: | (trunk()..@)-"];
fresh = ["new" "trunk()"];
tug = ["bookmark" "move" "--from" "closest_bookmark(@)" "--to" "closest_pushable(@)"];
};
snapshot = {
auto-track = "true";
max-new-file-size = 0;
};
fsmonitor = {
backend = "watchman";
watchman.register-snapshot-trigger = true;
};
user = {
name = cfg.name;
email = cfg.email;
};
ui = {
color = "auto";
movement.edit = true;
graph.style = "curved";
show-cryptographic-signatures = true;
pager = "delta";
diff-editor = ":builtin";
diff = {
color-words = {
conflict = "pair";
};
};
default-command = "log";
};
templates = {
log = ''
builtin_log_compact_full_description
'';
};
template-aliases = {
"format_short_signature(signature)" = "signature";
};
revset-aliases = {
"closest_bookmark(to)" = "heads(::to & bookmarks())";
"closest_pushable(to)" = "heads(::to & mutable() & ~description(exact:\"\") & (~empty() | merges()))";
"desc(x)" = "description(x)";
"pending()" = ".. ~ ::tags() ~ ::remote_bookmarks() ~ @ ~ private()";
"private()" = ''
description(glob:'wip:*') |
description(glob:'private:*') |
description(glob:'WIP:*') |
description(glob:'PRIVATE:*') |
conflicts() |
(empty() ~ merges()) |
description(substring-i:"DO NOT NAIL")
'';
};
git = {
abandon-unreachable-commits = false;
};
};
};
})
(lib.mkIf (cfg.enable && (cfg.signKey != null)) {
programs.jujutsu.settings = {
git = {
sign-on-push = true;
};
signing = {
behavior = "drop";
backend = "gpg";
key = cfg.signKey;
};
};
})
];
}