mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
patdiff: new module
Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
parent
4fef8e73a6
commit
c80be80282
5 changed files with 87 additions and 65 deletions
|
|
@ -316,16 +316,6 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
patdiff = {
|
|
||||||
enable = mkEnableOption "" // {
|
|
||||||
description = ''
|
|
||||||
Whether to enable the {command}`patdiff` differ.
|
|
||||||
See <https://opensource.janestreet.com/patdiff/>
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
package = mkPackageOption pkgs "patdiff" { };
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -355,8 +345,8 @@ in
|
||||||
(config.programs.diff-highlight.enable && config.programs.diff-highlight.enableGitIntegration)
|
(config.programs.diff-highlight.enable && config.programs.diff-highlight.enableGitIntegration)
|
||||||
(config.programs.diff-so-fancy.enable && config.programs.diff-so-fancy.enableGitIntegration)
|
(config.programs.diff-so-fancy.enable && config.programs.diff-so-fancy.enableGitIntegration)
|
||||||
(config.programs.difftastic.enable && config.programs.difftastic.git.enable)
|
(config.programs.difftastic.enable && config.programs.difftastic.git.enable)
|
||||||
|
(config.programs.patdiff.enable && config.programs.patdiff.enableGitIntegration)
|
||||||
cfg.riff.enable
|
cfg.riff.enable
|
||||||
cfg.patdiff.enable
|
|
||||||
];
|
];
|
||||||
in
|
in
|
||||||
lib.count lib.id enabled <= 1;
|
lib.count lib.id enabled <= 1;
|
||||||
|
|
@ -654,20 +644,6 @@ in
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
(
|
|
||||||
let
|
|
||||||
patdiffPackage = cfg.patdiff.package;
|
|
||||||
patdiffCommand = "${lib.getExe' patdiffPackage "patdiff-git-wrapper"}";
|
|
||||||
in
|
|
||||||
mkIf cfg.patdiff.enable {
|
|
||||||
home.packages = [ patdiffPackage ];
|
|
||||||
|
|
||||||
programs.git.iniContent = {
|
|
||||||
diff.external = patdiffCommand;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
(mkIf (cfg.riff.enable && cfg.riff.commandLineOptions != "") {
|
(mkIf (cfg.riff.enable && cfg.riff.commandLineOptions != "") {
|
||||||
home.sessionVariables.RIFF = cfg.riff.commandLineOptions;
|
home.sessionVariables.RIFF = cfg.riff.commandLineOptions;
|
||||||
})
|
})
|
||||||
|
|
|
||||||
86
modules/programs/patdiff.nix
Normal file
86
modules/programs/patdiff.nix
Normal file
|
|
@ -0,0 +1,86 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
options,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
cfg = config.programs.patdiff;
|
||||||
|
|
||||||
|
inherit (lib)
|
||||||
|
mkEnableOption
|
||||||
|
mkIf
|
||||||
|
mkPackageOption
|
||||||
|
mkOption
|
||||||
|
types
|
||||||
|
;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
meta.maintainers = with lib.maintainers; [ khaneliman ];
|
||||||
|
|
||||||
|
imports = [
|
||||||
|
(lib.mkRenamedOptionModule
|
||||||
|
[ "programs" "git" "patdiff" "enable" ]
|
||||||
|
[ "programs" "patdiff" "enable" ]
|
||||||
|
)
|
||||||
|
(lib.mkRenamedOptionModule
|
||||||
|
[ "programs" "git" "patdiff" "package" ]
|
||||||
|
[ "programs" "patdiff" "package" ]
|
||||||
|
)
|
||||||
|
];
|
||||||
|
|
||||||
|
options.programs.patdiff = {
|
||||||
|
enable = mkEnableOption "" // {
|
||||||
|
description = ''
|
||||||
|
Whether to enable the {command}`patdiff` differ.
|
||||||
|
See <https://opensource.janestreet.com/patdiff/>
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
package = mkPackageOption pkgs "patdiff" { };
|
||||||
|
|
||||||
|
enableGitIntegration = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = ''
|
||||||
|
Whether to enable git integration for patdiff.
|
||||||
|
|
||||||
|
When enabled, patdiff will be configured as git's external diff tool.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config =
|
||||||
|
let
|
||||||
|
oldOption = lib.attrByPath [ "programs" "git" "patdiff" "enable" ] null options;
|
||||||
|
oldOptionEnabled =
|
||||||
|
oldOption != null && oldOption.isDefined && (builtins.length oldOption.files) > 0;
|
||||||
|
in
|
||||||
|
lib.mkMerge [
|
||||||
|
(mkIf cfg.enable {
|
||||||
|
home.packages = [ cfg.package ];
|
||||||
|
|
||||||
|
# Auto-enable git integration if programs.git.patdiff.enable was set to true
|
||||||
|
programs.patdiff.enableGitIntegration = lib.mkIf oldOptionEnabled (lib.mkOverride 1490 true);
|
||||||
|
|
||||||
|
warnings =
|
||||||
|
lib.optional
|
||||||
|
(cfg.enableGitIntegration && options.programs.patdiff.enableGitIntegration.highestPrio == 1490)
|
||||||
|
"`programs.patdiff.enableGitIntegration` automatic enablement is deprecated. Please explicitly set `programs.patdiff.enableGitIntegration = true`.";
|
||||||
|
})
|
||||||
|
|
||||||
|
(mkIf (cfg.enable && cfg.enableGitIntegration) {
|
||||||
|
programs.git = {
|
||||||
|
enable = lib.mkDefault true;
|
||||||
|
iniContent =
|
||||||
|
let
|
||||||
|
patdiffCommand = "${lib.getExe' cfg.package "patdiff-git-wrapper"}";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
diff.external = patdiffCommand;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -10,5 +10,4 @@
|
||||||
git-with-hooks = ./git-with-hooks.nix;
|
git-with-hooks = ./git-with-hooks.nix;
|
||||||
git-with-lfs = ./git-with-lfs.nix;
|
git-with-lfs = ./git-with-lfs.nix;
|
||||||
git-with-maintenance = ./git-with-maintenance.nix;
|
git-with-maintenance = ./git-with-maintenance.nix;
|
||||||
git-patdiff = ./git-patdiff.nix;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
[commit]
|
|
||||||
gpgSign = true
|
|
||||||
|
|
||||||
[diff]
|
|
||||||
external = "@patdiff@/bin/patdiff-git-wrapper"
|
|
||||||
|
|
||||||
[gpg]
|
|
||||||
format = "openpgp"
|
|
||||||
|
|
||||||
[gpg "openpgp"]
|
|
||||||
program = "path-to-gpg"
|
|
||||||
|
|
||||||
[tag]
|
|
||||||
gpgSign = true
|
|
||||||
|
|
||||||
[user]
|
|
||||||
email = "user@example.org"
|
|
||||||
name = "John Doe"
|
|
||||||
signingKey = "00112233445566778899AABBCCDDEEFF"
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
{
|
|
||||||
programs.git = {
|
|
||||||
enable = true;
|
|
||||||
signing = {
|
|
||||||
signer = "path-to-gpg";
|
|
||||||
format = "openpgp";
|
|
||||||
key = "00112233445566778899AABBCCDDEEFF";
|
|
||||||
signByDefault = true;
|
|
||||||
};
|
|
||||||
userEmail = "user@example.org";
|
|
||||||
userName = "John Doe";
|
|
||||||
|
|
||||||
patdiff.enable = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
nmt.script = ''
|
|
||||||
assertFileExists home-files/.config/git/config
|
|
||||||
assertFileContent home-files/.config/git/config ${./git-patdiff-expected.conf}
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue