mirror of
https://github.com/nix-community/home-manager
synced 2024-11-22 12:43:14 +00:00
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
1 changed files with 21 additions and 1 deletions
|
@ -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" ];
|
||||
};
|
||||
}));
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue