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" ]; + }; + })); }; }; }