From 6e277d9566de9976f47228dd8c580b97488734d4 Mon Sep 17 00:00:00 2001 From: Bruno Bigras Date: Tue, 7 May 2024 06:25:03 -0400 Subject: [PATCH] jujutsu: add ediff option Based on . --- modules/programs/jujutsu.nix | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/modules/programs/jujutsu.nix b/modules/programs/jujutsu.nix index 269c5ef9..b1fcc703 100644 --- a/modules/programs/jujutsu.nix +++ b/modules/programs/jujutsu.nix @@ -22,6 +22,15 @@ in { package = mkPackageOption pkgs "jujutsu" { }; + ediff = mkOption { + type = types.bool; + default = config.programs.emacs.enable; + defaultText = literalExpression "config.programs.emacs.enable"; + description = '' + Enable ediff as a merge tool + ''; + }; + settings = mkOption { type = tomlFormat.type; default = { }; @@ -45,7 +54,18 @@ in { home.packages = [ cfg.package ]; home.file.".jjconfig.toml" = mkIf (cfg.settings != { }) { - source = tomlFormat.generate "jujutsu-config" cfg.settings; + source = tomlFormat.generate "jujutsu-config" (cfg.settings + // optionalAttrs (cfg.ediff) (let + emacsDiffScript = pkgs.writeShellScriptBin "emacs-ediff" '' + set -euxo pipefail + ${config.programs.emacs.package}/bin/emacsclient -c --eval "(ediff-merge-files-with-ancestor \"$1\" \"$2\" \"$3\" nil \"$4\")" + ''; + in { + merge-tools.ediff = { + program = getExe emacsDiffScript; + merge-args = [ "$left" "$right" "$base" "$output" ]; + }; + })); }; }; }