From 7c811bdff5f96d6793b13db79c408e39c860e30f Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Wed, 26 Feb 2025 10:51:31 +0000 Subject: [PATCH 1/4] WIP: add jujutsu (w/ Delta) --- modules/home/default.nix | 1 + modules/home/delta/default.nix | 29 ++++++++++ modules/home/jujutsu/default.nix | 91 ++++++++++++++++++++++++++++++++ 3 files changed, 121 insertions(+) create mode 100644 modules/home/jujutsu/default.nix diff --git a/modules/home/default.nix b/modules/home/default.nix index e642e87..4dbd510 100644 --- a/modules/home/default.nix +++ b/modules/home/default.nix @@ -24,6 +24,7 @@ ./gtk ./htop ./jq + ./jujutsu ./keyboard ./mail ./mpv diff --git a/modules/home/delta/default.nix b/modules/home/delta/default.nix index 58ee031..b301d2b 100644 --- a/modules/home/delta/default.nix +++ b/modules/home/delta/default.nix @@ -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}"; + }; + }; + }; }; } diff --git a/modules/home/jujutsu/default.nix b/modules/home/jujutsu/default.nix new file mode 100644 index 0000000..0c2d3b0 --- /dev/null +++ b/modules/home/jujutsu/default.nix @@ -0,0 +1,91 @@ +{ 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: + # * topo sort by default (I think? test it) + # * 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"; + }; + } + ]; + }; + }; + }; +} From 0fcf12f7510fde9f9cdba5c3f71664b7d5dbf890 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Mon, 17 Mar 2025 12:43:12 +0000 Subject: [PATCH 2/4] home: jj: use verbose draft commit messages --- modules/home/jujutsu/default.nix | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/modules/home/jujutsu/default.nix b/modules/home/jujutsu/default.nix index 0c2d3b0..56b845d 100644 --- a/modules/home/jujutsu/default.nix +++ b/modules/home/jujutsu/default.nix @@ -63,6 +63,27 @@ in # }; # }; + templates = { + # Equivalent to `commit.verbose = true` in Git + draft_commit_description = "commit_description_verbose(self)"; + }; + + template-aliases = { + "commit_description_verbose(commit)" = '' + concat( + commit_description(commit), + "JJ: ignore-rest\n", + diff.git(), + ) + ''; + "commit_description(commit)" = '' + concat( + commit.description(), "\n", + "JJ: This commit contains the following changes:\n", + indent("JJ: ", diff.stat(72)), + ) + ''; + }; "--scope" = [ # Multiple identities From 9cc70175f2c17d1f79d0578d29f17ef568ed91d9 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Mon, 17 Mar 2025 15:31:45 +0000 Subject: [PATCH 3/4] WIP: ADD NOTE FOR FUTURE SELF --- modules/home/jujutsu/default.nix | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/modules/home/jujutsu/default.nix b/modules/home/jujutsu/default.nix index 56b845d..956ad6b 100644 --- a/modules/home/jujutsu/default.nix +++ b/modules/home/jujutsu/default.nix @@ -49,7 +49,18 @@ in # * `root`: `jj workspace root` (barely necessary then) }; - # FIXME: `extraConfig` equivalents... + # FIXME: git equivalents + # blame = { + # coloring = "repeatedLines"; + # markIgnoredLines = true; + # markUnblamables = true; + # }; + # FIXME: log colors should probably match git + # FIXME: patience diff? + # FIXME: fetch prune/pruneTags? + # FIXME: pull.rebase=true? Probably true TBH + # FIXME: push.default=simple? Probably true TBH + # FIXME: conflict style? ui.conflict-marker-style=git is diff3/zdiff3 # FIXME: from ma_9's config, plus my own stuff # snapshot = { @@ -76,6 +87,9 @@ in diff.git(), ) ''; + # FIXME: use `diff.summary()` instead? Supported by syntax highlighting + # See https://github.com/jj-vcs/jj/issues/1946#issuecomment-2572986485 + # FIXME: tree-sitter grammar isn't in `nvim-treesitter` (https://github.com/kareigu/tree-sitter-jjdescription) "commit_description(commit)" = '' concat( commit.description(), "\n", From f761f11b6c653e7f060e7358a2cd30d3095efc6c Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Tue, 18 Mar 2025 14:59:23 +0000 Subject: [PATCH 4/4] home: jujutsu: explicitly create 'conf.d' This is to serve as a reminder of _how_ to add a local configuration file. --- modules/home/jujutsu/default.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/home/jujutsu/default.nix b/modules/home/jujutsu/default.nix index 956ad6b..a429bfa 100644 --- a/modules/home/jujutsu/default.nix +++ b/modules/home/jujutsu/default.nix @@ -122,5 +122,10 @@ in ]; }; }; + + # To drop in a `local.toml` configuration, not-versioned + xdg.configFile = { + "jj/conf.d/.keep".text = ""; + }; }; }