2017-01-07 18:16:26 +00:00
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
|
|
cfg = config.programs.git;
|
|
|
|
|
|
2019-03-12 23:06:36 +00:00
|
|
|
|
# create [section "subsection"] keys from "section.subsection" attrset names
|
|
|
|
|
mkSectionName = name:
|
|
|
|
|
let
|
|
|
|
|
containsQuote = strings.hasInfix ''"'' name;
|
|
|
|
|
sections = splitString "." name;
|
|
|
|
|
section = head sections;
|
|
|
|
|
subsections = tail sections;
|
|
|
|
|
subsection = concatStringsSep "." subsections;
|
2020-02-01 23:39:17 +00:00
|
|
|
|
in if containsQuote || subsections == [ ] then
|
|
|
|
|
name
|
|
|
|
|
else
|
|
|
|
|
''${section} "${subsection}"'';
|
2019-03-12 23:06:36 +00:00
|
|
|
|
|
2020-04-30 22:11:14 +00:00
|
|
|
|
mkValueString = v:
|
|
|
|
|
let
|
|
|
|
|
escapedV = ''
|
|
|
|
|
"${
|
|
|
|
|
replaceStrings [ "\n" " " ''"'' "\\" ] [ "\\n" "\\t" ''\"'' "\\\\" ] v
|
|
|
|
|
}"'';
|
|
|
|
|
in generators.mkValueStringDefault { } (if isString v then escapedV else v);
|
|
|
|
|
|
2019-03-12 08:35:55 +00:00
|
|
|
|
# generation for multiple ini values
|
|
|
|
|
mkKeyValue = k: v:
|
2020-04-30 22:11:14 +00:00
|
|
|
|
let
|
|
|
|
|
mkKeyValue =
|
|
|
|
|
generators.mkKeyValueDefault { inherit mkValueString; } " = " k;
|
2020-03-05 14:57:19 +00:00
|
|
|
|
in concatStringsSep "\n" (map (kv: " " + mkKeyValue kv) (toList v));
|
2019-03-12 08:35:55 +00:00
|
|
|
|
|
2019-03-12 23:06:36 +00:00
|
|
|
|
# converts { a.b.c = 5; } to { "a.b".c = 5; } for toINI
|
2020-02-01 23:39:17 +00:00
|
|
|
|
gitFlattenAttrs = let
|
|
|
|
|
recurse = path: value:
|
|
|
|
|
if isAttrs value then
|
|
|
|
|
mapAttrsToList (name: value: recurse ([ name ] ++ path) value) value
|
|
|
|
|
else if length path > 1 then {
|
|
|
|
|
${concatStringsSep "." (reverseList (tail path))}.${head path} = value;
|
|
|
|
|
} else {
|
|
|
|
|
${head path} = value;
|
|
|
|
|
};
|
|
|
|
|
in attrs: foldl recursiveUpdate { } (flatten (recurse [ ] attrs));
|
2019-03-12 23:06:36 +00:00
|
|
|
|
|
|
|
|
|
gitToIni = attrs:
|
2020-02-01 23:39:17 +00:00
|
|
|
|
let toIni = generators.toINI { inherit mkKeyValue mkSectionName; };
|
|
|
|
|
in toIni (gitFlattenAttrs attrs);
|
2019-03-12 08:35:55 +00:00
|
|
|
|
|
2019-02-01 00:06:18 +00:00
|
|
|
|
gitIniType = with types;
|
|
|
|
|
let
|
2019-03-12 08:35:55 +00:00
|
|
|
|
primitiveType = either str (either bool int);
|
|
|
|
|
multipleType = either primitiveType (listOf primitiveType);
|
|
|
|
|
sectionType = attrsOf multipleType;
|
2019-03-12 23:06:36 +00:00
|
|
|
|
supersectionType = attrsOf (either multipleType sectionType);
|
2020-02-01 23:39:17 +00:00
|
|
|
|
in attrsOf supersectionType;
|
2019-02-01 00:06:18 +00:00
|
|
|
|
|
2017-08-23 23:03:01 +00:00
|
|
|
|
signModule = types.submodule {
|
|
|
|
|
options = {
|
|
|
|
|
key = mkOption {
|
2021-04-05 12:28:36 +00:00
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
|
description = ''
|
|
|
|
|
The default GPG signing key fingerprint.
|
|
|
|
|
</para><para>
|
|
|
|
|
Set to <literal>null</literal> to let GnuPG decide what signing key
|
|
|
|
|
to use depending on commit’s author.
|
|
|
|
|
'';
|
2017-08-23 23:03:01 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
signByDefault = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = false;
|
2022-08-29 15:35:15 +00:00
|
|
|
|
description = "Whether commits and tags should be signed by default.";
|
2017-08-23 23:03:01 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
gpgPath = mkOption {
|
|
|
|
|
type = types.str;
|
|
|
|
|
default = "${pkgs.gnupg}/bin/gpg2";
|
|
|
|
|
defaultText = "\${pkgs.gnupg}/bin/gpg2";
|
|
|
|
|
description = "Path to GnuPG binary to use.";
|
2017-01-07 18:16:26 +00:00
|
|
|
|
};
|
2017-08-23 23:03:01 +00:00
|
|
|
|
};
|
|
|
|
|
};
|
2017-01-07 18:16:26 +00:00
|
|
|
|
|
2019-01-29 11:33:10 +00:00
|
|
|
|
includeModule = types.submodule ({ config, ... }: {
|
2018-04-18 21:41:20 +00:00
|
|
|
|
options = {
|
|
|
|
|
condition = mkOption {
|
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
|
default = null;
|
|
|
|
|
description = ''
|
|
|
|
|
Include this configuration only when <varname>condition</varname>
|
|
|
|
|
matches. Allowed conditions are described in
|
|
|
|
|
<citerefentry>
|
|
|
|
|
<refentrytitle>git-config</refentrytitle>
|
|
|
|
|
<manvolnum>1</manvolnum>
|
|
|
|
|
</citerefentry>.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
path = mkOption {
|
2019-01-29 11:33:10 +00:00
|
|
|
|
type = with types; either str path;
|
2018-04-18 21:41:20 +00:00
|
|
|
|
description = "Path of the configuration file to include.";
|
|
|
|
|
};
|
2019-01-29 11:33:10 +00:00
|
|
|
|
|
|
|
|
|
contents = mkOption {
|
2020-11-30 02:54:55 +00:00
|
|
|
|
type = types.attrsOf types.anything;
|
2020-02-01 23:39:17 +00:00
|
|
|
|
default = { };
|
2021-10-09 09:14:08 +00:00
|
|
|
|
example = literalExpression ''
|
2021-08-17 20:12:00 +00:00
|
|
|
|
{
|
|
|
|
|
user = {
|
|
|
|
|
email = "bob@work.example.com";
|
|
|
|
|
name = "Bob Work";
|
|
|
|
|
signingKey = "1A2B3C4D5E6F7G8H";
|
|
|
|
|
};
|
|
|
|
|
commit = {
|
|
|
|
|
gpgSign = true;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
'';
|
2019-01-29 11:33:10 +00:00
|
|
|
|
description = ''
|
|
|
|
|
Configuration to include. If empty then a path must be given.
|
2021-08-17 20:12:00 +00:00
|
|
|
|
|
|
|
|
|
This follows the configuration structure as described in
|
|
|
|
|
<citerefentry>
|
|
|
|
|
<refentrytitle>git-config</refentrytitle>
|
|
|
|
|
<manvolnum>1</manvolnum>
|
|
|
|
|
</citerefentry>.
|
2019-01-29 11:33:10 +00:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2022-08-26 19:48:50 +00:00
|
|
|
|
contentSuffix = mkOption {
|
|
|
|
|
type = types.str;
|
|
|
|
|
default = "gitconfig";
|
|
|
|
|
description = ''
|
|
|
|
|
Nix store name for the git configuration text file,
|
|
|
|
|
when generating the configuration text from nix options.
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
config.path = mkIf (config.contents != { }) (mkDefault
|
|
|
|
|
(pkgs.writeText (hm.strings.storeFileName config.contentSuffix)
|
|
|
|
|
(gitToIni config.contents)));
|
2019-01-29 11:33:10 +00:00
|
|
|
|
});
|
2018-04-18 21:41:20 +00:00
|
|
|
|
|
2020-02-01 23:39:17 +00:00
|
|
|
|
in {
|
2017-09-26 21:40:31 +00:00
|
|
|
|
meta.maintainers = [ maintainers.rycee ];
|
|
|
|
|
|
2017-01-07 18:16:26 +00:00
|
|
|
|
options = {
|
|
|
|
|
programs.git = {
|
|
|
|
|
enable = mkEnableOption "Git";
|
|
|
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
|
type = types.package;
|
|
|
|
|
default = pkgs.git;
|
2021-10-09 09:14:08 +00:00
|
|
|
|
defaultText = literalExpression "pkgs.git";
|
2019-01-21 08:14:22 +00:00
|
|
|
|
description = ''
|
|
|
|
|
Git package to install. Use <varname>pkgs.gitAndTools.gitFull</varname>
|
|
|
|
|
to gain access to <command>git send-email</command> for instance.
|
|
|
|
|
'';
|
2017-01-07 18:16:26 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
userName = mkOption {
|
2019-03-12 08:36:17 +00:00
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
|
default = null;
|
2017-01-07 18:16:26 +00:00
|
|
|
|
description = "Default user name to use.";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
userEmail = mkOption {
|
2019-03-12 08:36:17 +00:00
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
|
default = null;
|
2017-01-07 18:16:26 +00:00
|
|
|
|
description = "Default user email to use.";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
aliases = mkOption {
|
2019-02-01 00:06:18 +00:00
|
|
|
|
type = types.attrsOf types.str;
|
2020-02-01 23:39:17 +00:00
|
|
|
|
default = { };
|
2019-02-01 00:06:18 +00:00
|
|
|
|
example = { co = "checkout"; };
|
2017-01-07 18:16:26 +00:00
|
|
|
|
description = "Git aliases to define.";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
signing = mkOption {
|
|
|
|
|
type = types.nullOr signModule;
|
|
|
|
|
default = null;
|
|
|
|
|
description = "Options related to signing commits using GnuPG.";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extraConfig = mkOption {
|
2019-02-01 00:06:18 +00:00
|
|
|
|
type = types.either types.lines gitIniType;
|
2020-02-01 23:39:17 +00:00
|
|
|
|
default = { };
|
2019-02-01 00:06:18 +00:00
|
|
|
|
example = {
|
|
|
|
|
core = { whitespace = "trailing-space,space-before-tab"; };
|
2019-03-12 23:06:36 +00:00
|
|
|
|
url."ssh://git@host".insteadOf = "otherhost";
|
2019-02-01 00:06:18 +00:00
|
|
|
|
};
|
2019-08-30 12:50:10 +00:00
|
|
|
|
description = ''
|
|
|
|
|
Additional configuration to add. The use of string values is
|
|
|
|
|
deprecated and will be removed in the future.
|
|
|
|
|
'';
|
2017-01-07 18:16:26 +00:00
|
|
|
|
};
|
2017-09-21 12:45:20 +00:00
|
|
|
|
|
2022-09-04 16:57:45 +00:00
|
|
|
|
hooks = mkOption {
|
|
|
|
|
type = types.attrsOf types.path;
|
|
|
|
|
default = { };
|
|
|
|
|
example = literalExpression ''
|
|
|
|
|
{
|
|
|
|
|
pre-commit = ./pre-commit-script;
|
|
|
|
|
}
|
|
|
|
|
'';
|
|
|
|
|
description = ''
|
|
|
|
|
Configuration helper for Git hooks.
|
|
|
|
|
See <link xlink:href="https://git-scm.com/docs/githooks" />
|
|
|
|
|
for reference.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2017-09-21 12:45:20 +00:00
|
|
|
|
iniContent = mkOption {
|
2019-02-01 00:06:18 +00:00
|
|
|
|
type = gitIniType;
|
2017-09-21 12:45:20 +00:00
|
|
|
|
internal = true;
|
|
|
|
|
};
|
2017-11-12 12:28:12 +00:00
|
|
|
|
|
|
|
|
|
ignores = mkOption {
|
|
|
|
|
type = types.listOf types.str;
|
2020-02-01 23:39:17 +00:00
|
|
|
|
default = [ ];
|
2017-11-12 12:28:12 +00:00
|
|
|
|
example = [ "*~" "*.swp" ];
|
|
|
|
|
description = "List of paths that should be globally ignored.";
|
|
|
|
|
};
|
2018-04-18 21:41:20 +00:00
|
|
|
|
|
2019-09-24 09:20:00 +00:00
|
|
|
|
attributes = mkOption {
|
|
|
|
|
type = types.listOf types.str;
|
2020-02-01 23:39:17 +00:00
|
|
|
|
default = [ ];
|
2019-09-24 09:20:00 +00:00
|
|
|
|
example = [ "*.pdf diff=pdf" ];
|
|
|
|
|
description = "List of defining attributes set globally.";
|
|
|
|
|
};
|
|
|
|
|
|
2018-04-18 21:41:20 +00:00
|
|
|
|
includes = mkOption {
|
|
|
|
|
type = types.listOf includeModule;
|
2020-02-01 23:39:17 +00:00
|
|
|
|
default = [ ];
|
2021-10-09 09:14:08 +00:00
|
|
|
|
example = literalExpression ''
|
2018-04-18 21:41:20 +00:00
|
|
|
|
[
|
|
|
|
|
{ path = "~/path/to/config.inc"; }
|
|
|
|
|
{
|
|
|
|
|
path = "~/path/to/conditional.inc";
|
|
|
|
|
condition = "gitdir:~/src/dir";
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
'';
|
|
|
|
|
description = "List of configuration files to include.";
|
|
|
|
|
};
|
2019-02-03 22:54:29 +00:00
|
|
|
|
|
|
|
|
|
lfs = {
|
|
|
|
|
enable = mkEnableOption "Git Large File Storage";
|
|
|
|
|
|
|
|
|
|
skipSmudge = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = false;
|
|
|
|
|
description = ''
|
|
|
|
|
Skip automatic downloading of objects on clone or pull.
|
|
|
|
|
This requires a manual <command>git lfs pull</command>
|
|
|
|
|
every time a new commit is checked out on your repository.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
};
|
2020-04-26 09:20:00 +00:00
|
|
|
|
|
2022-04-04 14:53:29 +00:00
|
|
|
|
difftastic = {
|
|
|
|
|
enable = mkEnableOption "" // {
|
|
|
|
|
description = ''
|
2022-12-03 04:20:00 +00:00
|
|
|
|
Enable the <command>difftastic</command> syntax highlighter.
|
2022-04-04 14:53:29 +00:00
|
|
|
|
See <link xlink:href="https://github.com/Wilfred/difftastic" />.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
background = mkOption {
|
|
|
|
|
type = types.enum [ "light" "dark" ];
|
|
|
|
|
default = "light";
|
|
|
|
|
example = "dark";
|
|
|
|
|
description = ''
|
|
|
|
|
Determines whether difftastic should use the lighter or darker colors
|
2022-12-03 04:20:00 +00:00
|
|
|
|
for syntax highlighting.
|
2022-04-04 14:53:29 +00:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
color = mkOption {
|
|
|
|
|
type = types.enum [ "always" "auto" "never" ];
|
|
|
|
|
default = "auto";
|
|
|
|
|
example = "always";
|
|
|
|
|
description = ''
|
|
|
|
|
Determines when difftastic should color its output.
|
|
|
|
|
'';
|
|
|
|
|
};
|
2022-07-08 17:26:09 +00:00
|
|
|
|
|
|
|
|
|
display = mkOption {
|
|
|
|
|
type =
|
|
|
|
|
types.enum [ "side-by-side" "side-by-side-show-both" "inline" ];
|
|
|
|
|
default = "side-by-side";
|
|
|
|
|
example = "inline";
|
|
|
|
|
description = ''
|
|
|
|
|
Determines how the output displays - in one column or two columns.
|
|
|
|
|
'';
|
|
|
|
|
};
|
2022-04-04 14:53:29 +00:00
|
|
|
|
};
|
|
|
|
|
|
2020-04-26 09:20:00 +00:00
|
|
|
|
delta = {
|
|
|
|
|
enable = mkEnableOption "" // {
|
|
|
|
|
description = ''
|
|
|
|
|
Whether to enable the <command>delta</command> syntax highlighter.
|
|
|
|
|
See <link xlink:href="https://github.com/dandavison/delta" />.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
options = mkOption {
|
2020-07-20 15:03:40 +00:00
|
|
|
|
type = with types;
|
|
|
|
|
let
|
|
|
|
|
primitiveType = either str (either bool int);
|
|
|
|
|
sectionType = attrsOf primitiveType;
|
|
|
|
|
in attrsOf (either primitiveType sectionType);
|
|
|
|
|
default = { };
|
|
|
|
|
example = {
|
|
|
|
|
features = "decorations";
|
|
|
|
|
whitespace-error-style = "22 reverse";
|
|
|
|
|
decorations = {
|
|
|
|
|
commit-decoration-style = "bold yellow box ul";
|
|
|
|
|
file-style = "bold yellow ul";
|
|
|
|
|
file-decoration-style = "none";
|
|
|
|
|
};
|
|
|
|
|
};
|
2020-04-26 09:20:00 +00:00
|
|
|
|
description = ''
|
2020-07-20 15:03:40 +00:00
|
|
|
|
Options to configure delta.
|
2020-04-26 09:20:00 +00:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
};
|
2022-04-09 19:45:30 +00:00
|
|
|
|
|
|
|
|
|
diff-so-fancy = {
|
|
|
|
|
enable = mkEnableOption "" // {
|
|
|
|
|
description = ''
|
|
|
|
|
Enable the <command>diff-so-fancy</command> diff colorizer.
|
|
|
|
|
See <link xlink:href="https://github.com/so-fancy/diff-so-fancy" />.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2023-02-27 12:04:46 +00:00
|
|
|
|
pagerOpts = mkOption {
|
|
|
|
|
type = types.listOf types.str;
|
|
|
|
|
default = [ "--tabs=4" "-RFX" ];
|
|
|
|
|
description = ''
|
|
|
|
|
Arguments to be passed to <command>less</command>.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2022-04-09 19:45:30 +00:00
|
|
|
|
markEmptyLines = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = true;
|
|
|
|
|
example = false;
|
|
|
|
|
description = ''
|
|
|
|
|
Whether the first block of an empty line should be colored.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
changeHunkIndicators = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = true;
|
|
|
|
|
example = false;
|
|
|
|
|
description = ''
|
|
|
|
|
Simplify git header chunks to a more human readable format.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
stripLeadingSymbols = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = true;
|
|
|
|
|
example = false;
|
|
|
|
|
description = ''
|
|
|
|
|
Whether the <literal>+</literal> or <literal>-</literal> at
|
|
|
|
|
line-start should be removed.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
useUnicodeRuler = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = true;
|
|
|
|
|
example = false;
|
|
|
|
|
description = ''
|
|
|
|
|
By default, the separator for the file header uses Unicode
|
|
|
|
|
line-drawing characters. If this is causing output errors on
|
|
|
|
|
your terminal, set this to false to use ASCII characters instead.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
rulerWidth = mkOption {
|
|
|
|
|
type = types.nullOr types.int;
|
|
|
|
|
default = null;
|
|
|
|
|
example = false;
|
|
|
|
|
description = ''
|
|
|
|
|
By default, the separator for the file header spans the full
|
|
|
|
|
width of the terminal. Use this setting to set the width of
|
|
|
|
|
the file header manually.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
};
|
2017-01-07 18:16:26 +00:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2020-02-01 23:39:17 +00:00
|
|
|
|
config = mkIf cfg.enable (mkMerge [
|
|
|
|
|
{
|
|
|
|
|
home.packages = [ cfg.package ];
|
2022-04-04 14:53:29 +00:00
|
|
|
|
assertions = [{
|
2022-04-09 19:45:30 +00:00
|
|
|
|
assertion = let
|
|
|
|
|
enabled =
|
|
|
|
|
[ cfg.delta.enable cfg.diff-so-fancy.enable cfg.difftastic.enable ];
|
|
|
|
|
in count id enabled <= 1;
|
2022-04-04 14:53:29 +00:00
|
|
|
|
message =
|
2022-04-09 19:45:30 +00:00
|
|
|
|
"Only one of 'programs.git.delta.enable' or 'programs.git.difftastic.enable' or 'programs.git.diff-so-fancy.enable' can be set to true at the same time.";
|
2022-04-04 14:53:29 +00:00
|
|
|
|
}];
|
2017-09-21 12:45:20 +00:00
|
|
|
|
|
2020-02-01 23:39:17 +00:00
|
|
|
|
programs.git.iniContent.user = {
|
|
|
|
|
name = mkIf (cfg.userName != null) cfg.userName;
|
|
|
|
|
email = mkIf (cfg.userEmail != null) cfg.userEmail;
|
|
|
|
|
};
|
2017-01-07 18:16:26 +00:00
|
|
|
|
|
2020-02-01 23:39:17 +00:00
|
|
|
|
xdg.configFile = {
|
|
|
|
|
"git/config".text = gitToIni cfg.iniContent;
|
2017-11-12 12:28:12 +00:00
|
|
|
|
|
2020-02-01 23:39:17 +00:00
|
|
|
|
"git/ignore" = mkIf (cfg.ignores != [ ]) {
|
|
|
|
|
text = concatStringsSep "\n" cfg.ignores + "\n";
|
|
|
|
|
};
|
2019-09-24 09:20:00 +00:00
|
|
|
|
|
2020-02-01 23:39:17 +00:00
|
|
|
|
"git/attributes" = mkIf (cfg.attributes != [ ]) {
|
|
|
|
|
text = concatStringsSep "\n" cfg.attributes + "\n";
|
2017-11-12 12:28:12 +00:00
|
|
|
|
};
|
2020-02-01 23:39:17 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
programs.git.iniContent = let
|
|
|
|
|
hasSmtp = name: account: account.smtp != null;
|
|
|
|
|
|
|
|
|
|
genIdentity = name: account:
|
|
|
|
|
with account;
|
2021-02-28 15:06:11 +00:00
|
|
|
|
nameValuePair "sendemail.${name}" (if account.msmtp.enable then {
|
|
|
|
|
smtpServer = "${pkgs.msmtp}/bin/msmtp";
|
2021-02-28 19:42:44 +00:00
|
|
|
|
envelopeSender = "auto";
|
2020-02-01 23:39:17 +00:00
|
|
|
|
from = address;
|
2021-02-28 15:06:11 +00:00
|
|
|
|
} else
|
|
|
|
|
{
|
|
|
|
|
smtpEncryption = if smtp.tls.enable then
|
|
|
|
|
(if smtp.tls.useStartTls
|
|
|
|
|
|| versionOlder config.home.stateVersion "20.09" then
|
|
|
|
|
"tls"
|
|
|
|
|
else
|
|
|
|
|
"ssl")
|
|
|
|
|
else
|
|
|
|
|
"";
|
2021-08-02 18:23:50 +00:00
|
|
|
|
smtpSslCertPath =
|
|
|
|
|
mkIf smtp.tls.enable (toString smtp.tls.certificatesFile);
|
2021-02-28 15:06:11 +00:00
|
|
|
|
smtpServer = smtp.host;
|
|
|
|
|
smtpUser = userName;
|
|
|
|
|
from = address;
|
|
|
|
|
} // optionalAttrs (smtp.port != null) {
|
|
|
|
|
smtpServerPort = smtp.port;
|
|
|
|
|
});
|
2020-02-01 23:39:17 +00:00
|
|
|
|
in mapAttrs' genIdentity
|
|
|
|
|
(filterAttrs hasSmtp config.accounts.email.accounts);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
(mkIf (cfg.signing != null) {
|
|
|
|
|
programs.git.iniContent = {
|
2021-04-05 12:28:36 +00:00
|
|
|
|
user.signingKey = mkIf (cfg.signing.key != null) cfg.signing.key;
|
2023-03-02 11:27:57 +00:00
|
|
|
|
commit.gpgSign = mkDefault cfg.signing.signByDefault;
|
|
|
|
|
tag.gpgSign = mkDefault cfg.signing.signByDefault;
|
2020-02-01 23:39:17 +00:00
|
|
|
|
gpg.program = cfg.signing.gpgPath;
|
|
|
|
|
};
|
|
|
|
|
})
|
|
|
|
|
|
2022-09-04 16:57:45 +00:00
|
|
|
|
(mkIf (cfg.hooks != { }) {
|
|
|
|
|
programs.git.iniContent = {
|
|
|
|
|
core.hooksPath = let
|
|
|
|
|
entries =
|
|
|
|
|
mapAttrsToList (name: path: { inherit name path; }) cfg.hooks;
|
|
|
|
|
in toString (pkgs.linkFarm "git-hooks" entries);
|
|
|
|
|
};
|
|
|
|
|
})
|
|
|
|
|
|
2020-02-01 23:39:17 +00:00
|
|
|
|
(mkIf (cfg.aliases != { }) { programs.git.iniContent.alias = cfg.aliases; })
|
|
|
|
|
|
|
|
|
|
(mkIf (lib.isAttrs cfg.extraConfig) {
|
|
|
|
|
programs.git.iniContent = cfg.extraConfig;
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
(mkIf (lib.isString cfg.extraConfig) {
|
|
|
|
|
warnings = [''
|
|
|
|
|
Using programs.git.extraConfig as a string option is
|
|
|
|
|
deprecated and will be removed in the future. Please
|
|
|
|
|
change to using it as an attribute set instead.
|
|
|
|
|
''];
|
|
|
|
|
|
|
|
|
|
xdg.configFile."git/config".text = cfg.extraConfig;
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
(mkIf (cfg.includes != [ ]) {
|
|
|
|
|
xdg.configFile."git/config".text = let
|
|
|
|
|
include = i:
|
|
|
|
|
with i;
|
|
|
|
|
if condition != null then {
|
|
|
|
|
includeIf.${condition}.path = "${path}";
|
|
|
|
|
} else {
|
|
|
|
|
include.path = "${path}";
|
|
|
|
|
};
|
|
|
|
|
in mkAfter
|
|
|
|
|
(concatStringsSep "\n" (map gitToIni (map include cfg.includes)));
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
(mkIf cfg.lfs.enable {
|
|
|
|
|
home.packages = [ pkgs.git-lfs ];
|
|
|
|
|
|
|
|
|
|
programs.git.iniContent.filter.lfs =
|
|
|
|
|
let skipArg = optional cfg.lfs.skipSmudge "--skip";
|
|
|
|
|
in {
|
|
|
|
|
clean = "git-lfs clean -- %f";
|
|
|
|
|
process =
|
|
|
|
|
concatStringsSep " " ([ "git-lfs" "filter-process" ] ++ skipArg);
|
|
|
|
|
required = true;
|
|
|
|
|
smudge = concatStringsSep " "
|
|
|
|
|
([ "git-lfs" "smudge" ] ++ skipArg ++ [ "--" "%f" ]);
|
2017-09-21 12:45:20 +00:00
|
|
|
|
};
|
2020-02-01 23:39:17 +00:00
|
|
|
|
})
|
2020-04-26 09:20:00 +00:00
|
|
|
|
|
2022-04-04 14:53:29 +00:00
|
|
|
|
(mkIf cfg.difftastic.enable {
|
|
|
|
|
home.packages = [ pkgs.difftastic ];
|
|
|
|
|
|
|
|
|
|
programs.git.iniContent = let
|
2022-07-08 17:26:09 +00:00
|
|
|
|
difftCommand = concatStringsSep " " [
|
|
|
|
|
"${pkgs.difftastic}/bin/difft"
|
|
|
|
|
"--color ${cfg.difftastic.color}"
|
|
|
|
|
"--background ${cfg.difftastic.background}"
|
|
|
|
|
"--display ${cfg.difftastic.display}"
|
|
|
|
|
];
|
2023-02-02 01:58:17 +00:00
|
|
|
|
in { diff.external = difftCommand; };
|
2022-04-04 14:53:29 +00:00
|
|
|
|
})
|
|
|
|
|
|
2020-04-26 09:20:00 +00:00
|
|
|
|
(mkIf cfg.delta.enable {
|
2021-03-18 22:32:50 +00:00
|
|
|
|
home.packages = [ pkgs.delta ];
|
|
|
|
|
|
2021-01-20 17:58:17 +00:00
|
|
|
|
programs.git.iniContent = let deltaCommand = "${pkgs.delta}/bin/delta";
|
|
|
|
|
in {
|
|
|
|
|
core.pager = deltaCommand;
|
|
|
|
|
interactive.diffFilter = "${deltaCommand} --color-only";
|
|
|
|
|
delta = cfg.delta.options;
|
|
|
|
|
};
|
2020-04-26 09:20:00 +00:00
|
|
|
|
})
|
2022-04-09 19:45:30 +00:00
|
|
|
|
|
|
|
|
|
(mkIf cfg.diff-so-fancy.enable {
|
|
|
|
|
home.packages = [ pkgs.diff-so-fancy ];
|
|
|
|
|
|
|
|
|
|
programs.git.iniContent =
|
|
|
|
|
let dsfCommand = "${pkgs.diff-so-fancy}/bin/diff-so-fancy";
|
|
|
|
|
in {
|
2023-02-27 12:04:46 +00:00
|
|
|
|
core.pager = "${dsfCommand} | ${pkgs.less}/bin/less ${
|
|
|
|
|
escapeShellArgs cfg.diff-so-fancy.pagerOpts
|
|
|
|
|
}";
|
2022-04-09 19:45:30 +00:00
|
|
|
|
interactive.diffFilter = "${dsfCommand} --patch";
|
|
|
|
|
diff-so-fancy = {
|
|
|
|
|
markEmptyLines = cfg.diff-so-fancy.markEmptyLines;
|
|
|
|
|
changeHunkIndicators = cfg.diff-so-fancy.changeHunkIndicators;
|
|
|
|
|
stripLeadingSymbols = cfg.diff-so-fancy.stripLeadingSymbols;
|
|
|
|
|
useUnicodeRuler = cfg.diff-so-fancy.useUnicodeRuler;
|
|
|
|
|
rulerWidth = mkIf (cfg.diff-so-fancy.rulerWidth != null)
|
|
|
|
|
(cfg.diff-so-fancy.rulerWidth);
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
})
|
2020-02-01 23:39:17 +00:00
|
|
|
|
]);
|
2017-01-07 18:16:26 +00:00
|
|
|
|
}
|