jujutsu: add ediff option
Based on <https://github.com/martinvonz/jj/wiki/Emacs#ediff-as-a-merge-tool>.
This commit is contained in:
parent
6ebe7be2e6
commit
6e277d9566
|
@ -22,6 +22,15 @@ in {
|
||||||
|
|
||||||
package = mkPackageOption pkgs "jujutsu" { };
|
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 {
|
settings = mkOption {
|
||||||
type = tomlFormat.type;
|
type = tomlFormat.type;
|
||||||
default = { };
|
default = { };
|
||||||
|
@ -45,7 +54,18 @@ in {
|
||||||
home.packages = [ cfg.package ];
|
home.packages = [ cfg.package ];
|
||||||
|
|
||||||
home.file.".jjconfig.toml" = mkIf (cfg.settings != { }) {
|
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" ];
|
||||||
|
};
|
||||||
|
}));
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue