WIP: add jujutsu (w/ Delta)

This commit is contained in:
Bruno BELANYI 2025-02-26 10:51:31 +00:00
parent 7786c591b5
commit 212f80695a
3 changed files with 120 additions and 0 deletions

View file

@ -24,6 +24,7 @@
./gtk
./htop
./jq
./jujutsu
./keyboard
./mail
./mpv

View file

@ -11,6 +11,10 @@ in
git = {
enable = my.mkDisableOption "git integration";
};
jujutsu = {
enable = my.mkDisableOption "jujutsu integration";
};
};
config = lib.mkIf cfg.enable {
@ -30,6 +34,13 @@ in
enabled.
'';
}
{
assertion = cfg.jujutsu.enable -> cfg.git.enable;
message = ''
`config.my.home.delta.jujutsu` relies on `config.my.home.delta.git`
being enabled.
'';
}
];
home.packages = [ cfg.package ];
@ -64,5 +75,23 @@ in
};
};
};
programs.jujutsu = lib.mkIf cfg.jujutsu.enable {
settings = {
merge-tools = {
delta = {
# Errors are signaled with exit codes greater or equal to 2
diff-expected-exit-codes = [ 0 1 ];
};
};
ui = {
# Delta expects a `git diff` input
diff-formatter = ":git";
pager = "${lib.getExe cfg.package}";
};
};
};
};
}

View file

@ -0,0 +1,90 @@
{ config, pkgs, lib, ... }:
let
cfg = config.my.home.jujutsu;
inherit (lib.my) mkMailAddress;
in
{
options.my.home.jujutsu = with lib; {
enable = my.mkDisableOption "jujutsu configuration";
package = mkPackageOption pkgs "jujutsu" { };
};
config = lib.mkIf cfg.enable {
assertions = [
{
# For `jj git` commands
assertion = cfg.enable -> config.my.home.git.enable;
message = ''
`config.my.home.jujutsu` relies on `config.my.home.git` being enabled.
'';
}
];
programs.jujutsu = {
enable = true;
inherit (cfg) package;
settings = {
# Who am I?
user = {
name = "Bruno BELANYI";
email = mkMailAddress "bruno" "belanyi.fr";
};
aliases = {
jj = [ "util" "exec" "--" "jj" ];
# FIXME:
# * still not a big fan of the template
lol = [ "log" "-r" "..@" "-T" "builtin_log_oneline" ];
lola = [ "lol" "-r" "all()" ];
# FIXME: equivalent to `git switch -`
# See https://github.com/jj-vcs/jj/issues/2871
# Might be broken recently https://discord.com/channels/968932220549103686/1380272574709366989/1380432041983606855
# TODO:
# * `pick` (https://github.com/jj-vcs/jj/issues/5446): [ "util" "exec" "--" "bash" "-c" "jj log -p -r \"diff_contains($1)\"" "" ]
# * `root`: `jj workspace root` (barely necessary then)
};
# FIXME: `extraConfig` equivalents...
# FIXME: from ma_9's config, plus my own stuff
# snapshot = {
# auto-track = "none()";
# };
#
# ui = {
# diff-editor = ":builtin"; # To silence hints
# movement = {
# edit = false;
# };
# };
"--scope" = [
# Multiple identities
{
"--when" = {
repositories = [ "~/git/EPITA/" ];
};
user = {
name = "Bruno BELANYI";
email = mkMailAddress "bruno.belanyi" "epita.fr";
};
}
{
"--when" = {
repositories = [ "~/git/work/" ];
};
user = {
name = "Bruno BELANYI";
email = mkMailAddress "ambroisie" "google.com";
};
}
];
};
};
};
}