jujutsu: add ediff option

Based on <https://github.com/martinvonz/jj/wiki/Emacs#ediff-as-a-merge-tool>.
This commit is contained in:
Bruno Bigras 2024-05-07 06:25:03 -04:00 committed by GitHub
parent 6ebe7be2e6
commit 6e277d9566
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 21 additions and 1 deletions

View File

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