ec: init module

Adds Home Manager module for ec, a 3-way terminal native Git merge conflict resolver.

The module supports:
- Git integration by configuring ec as a mergetool.
This commit is contained in:
Kristoffer Plagborg Bak Sørensen
2026-05-18 17:35:29 +02:00
committed by GitHub
parent 74f170c62d
commit 7519f615df
5 changed files with 67 additions and 0 deletions

42
modules/programs/ec.nix Normal file
View File

@@ -0,0 +1,42 @@
{
pkgs,
config,
lib,
...
}:
let
cfg = config.programs.ec;
ec = lib.getExe cfg.package;
in
{
meta.maintainers = [ lib.maintainers.kpbaks ];
options = {
programs.ec = {
enable = lib.mkEnableOption "ec, 3-way terminal native Git merge conflict resolver";
package = lib.mkPackageOption pkgs "ec" { };
enableGitIntegration = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to enable git integration for ec.
When enabled, ec will be configured as git's merge tool.
'';
};
};
};
config = lib.mkIf cfg.enable {
home.packages = [ cfg.package ];
programs.git.settings = lib.mkIf cfg.enableGitIntegration {
merge.tool = "ec";
mergetool.ec = {
cmd = ''${ec} "$BASE" "$LOCAL" "$REMOTE" "$MERGED"'';
trustExitCode = true;
};
};
};
}

View File

@@ -49,6 +49,7 @@ let
"discord"
"discoss"
"earthly"
"ec"
"element-desktop"
"emacs"
"espanso"

View File

@@ -0,0 +1,9 @@
{
programs.git.enable = true;
programs.ec.enable = true;
programs.ec.enableGitIntegration = true;
nmt.script = ''
assertFileContent "home-files/.config/git/config" ${./ec-git.conf}
'';
}

View File

@@ -0,0 +1,3 @@
{
ec-basic-configuration = ./basic-configuration.nix;
}

View File

@@ -0,0 +1,12 @@
[gpg]
format = "openpgp"
[gpg "openpgp"]
program = "@gnupg@/bin/gpg"
[merge]
tool = "ec"
[mergetool "ec"]
cmd = "@ec@/bin/ec \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\""
trustExitCode = true