2017-01-07 19:16:26 +01:00
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
|
|
cfg = config.programs.git;
|
|
|
|
|
|
2019-02-01 01:06:18 +01:00
|
|
|
|
gitIniType = with types;
|
|
|
|
|
let
|
2019-03-12 09:35:55 +01:00
|
|
|
|
primitiveType = either str (either bool int);
|
|
|
|
|
multipleType = either primitiveType (listOf primitiveType);
|
|
|
|
|
sectionType = attrsOf multipleType;
|
2019-03-13 00:06:36 +01:00
|
|
|
|
supersectionType = attrsOf (either multipleType sectionType);
|
2020-02-02 00:39:17 +01:00
|
|
|
|
in attrsOf supersectionType;
|
2019-02-01 01:06:18 +01:00
|
|
|
|
|
2017-08-24 01:03:01 +02:00
|
|
|
|
signModule = types.submodule {
|
|
|
|
|
options = {
|
|
|
|
|
key = mkOption {
|
2021-04-05 14:28:36 +02:00
|
|
|
|
type = types.nullOr types.str;
|
2023-07-02 01:45:18 +02:00
|
|
|
|
description = ''
|
2021-04-05 14:28:36 +02:00
|
|
|
|
The default GPG signing key fingerprint.
|
2023-07-01 01:30:13 +02:00
|
|
|
|
|
|
|
|
|
Set to `null` to let GnuPG decide what signing key
|
2021-04-05 14:28:36 +02:00
|
|
|
|
to use depending on commit’s author.
|
|
|
|
|
'';
|
2017-08-24 01:03:01 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
signByDefault = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = false;
|
2023-07-02 01:45:18 +02:00
|
|
|
|
description = "Whether commits and tags should be signed by default.";
|
2017-08-24 01:03:01 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
gpgPath = mkOption {
|
|
|
|
|
type = types.str;
|
|
|
|
|
default = "${pkgs.gnupg}/bin/gpg2";
|
|
|
|
|
defaultText = "\${pkgs.gnupg}/bin/gpg2";
|
2023-07-02 01:45:18 +02:00
|
|
|
|
description = "Path to GnuPG binary to use.";
|
2017-01-07 19:16:26 +01:00
|
|
|
|
};
|
2017-08-24 01:03:01 +02:00
|
|
|
|
};
|
|
|
|
|
};
|
2017-01-07 19:16:26 +01:00
|
|
|
|
|
2019-01-29 12:33:10 +01:00
|
|
|
|
includeModule = types.submodule ({ config, ... }: {
|
2018-04-18 23:41:20 +02:00
|
|
|
|
options = {
|
|
|
|
|
condition = mkOption {
|
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
|
default = null;
|
2023-07-02 01:45:18 +02:00
|
|
|
|
description = ''
|
2023-07-01 01:30:13 +02:00
|
|
|
|
Include this configuration only when {var}`condition`
|
2018-04-18 23:41:20 +02:00
|
|
|
|
matches. Allowed conditions are described in
|
2023-07-01 01:30:13 +02:00
|
|
|
|
{manpage}`git-config(1)`.
|
2018-04-18 23:41:20 +02:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
path = mkOption {
|
2019-01-29 12:33:10 +01:00
|
|
|
|
type = with types; either str path;
|
2023-07-02 01:45:18 +02:00
|
|
|
|
description = "Path of the configuration file to include.";
|
2018-04-18 23:41:20 +02:00
|
|
|
|
};
|
2019-01-29 12:33:10 +01:00
|
|
|
|
|
|
|
|
|
contents = mkOption {
|
2020-11-30 03:54:55 +01:00
|
|
|
|
type = types.attrsOf types.anything;
|
2020-02-02 00:39:17 +01:00
|
|
|
|
default = { };
|
2021-10-09 11:14:08 +02:00
|
|
|
|
example = literalExpression ''
|
2021-08-17 22:12:00 +02:00
|
|
|
|
{
|
|
|
|
|
user = {
|
|
|
|
|
email = "bob@work.example.com";
|
|
|
|
|
name = "Bob Work";
|
|
|
|
|
signingKey = "1A2B3C4D5E6F7G8H";
|
|
|
|
|
};
|
|
|
|
|
commit = {
|
|
|
|
|
gpgSign = true;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
'';
|
2023-07-02 01:45:18 +02:00
|
|
|
|
description = ''
|
2019-01-29 12:33:10 +01:00
|
|
|
|
Configuration to include. If empty then a path must be given.
|
2021-08-17 22:12:00 +02:00
|
|
|
|
|
|
|
|
|
This follows the configuration structure as described in
|
2023-07-01 01:30:13 +02:00
|
|
|
|
{manpage}`git-config(1)`.
|
2019-01-29 12:33:10 +01:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2022-08-26 21:48:50 +02:00
|
|
|
|
contentSuffix = mkOption {
|
|
|
|
|
type = types.str;
|
|
|
|
|
default = "gitconfig";
|
2023-07-02 01:45:18 +02:00
|
|
|
|
description = ''
|
2022-08-26 21:48:50 +02:00
|
|
|
|
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)
|
2023-08-21 09:35:43 +02:00
|
|
|
|
(generators.toGitINI config.contents)));
|
2019-01-29 12:33:10 +01:00
|
|
|
|
});
|
2018-04-18 23:41:20 +02:00
|
|
|
|
|
2020-02-02 00:39:17 +01:00
|
|
|
|
in {
|
2017-09-26 23:40:31 +02:00
|
|
|
|
meta.maintainers = [ maintainers.rycee ];
|
|
|
|
|
|
2017-01-07 19:16:26 +01:00
|
|
|
|
options = {
|
|
|
|
|
programs.git = {
|
2023-07-02 01:45:18 +02:00
|
|
|
|
enable = mkEnableOption "Git";
|
2017-01-07 19:16:26 +01:00
|
|
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
|
type = types.package;
|
|
|
|
|
default = pkgs.git;
|
2021-10-09 11:14:08 +02:00
|
|
|
|
defaultText = literalExpression "pkgs.git";
|
2023-07-02 01:45:18 +02:00
|
|
|
|
description = ''
|
2023-07-01 01:30:13 +02:00
|
|
|
|
Git package to install. Use {var}`pkgs.gitAndTools.gitFull`
|
|
|
|
|
to gain access to {command}`git send-email` for instance.
|
2019-01-21 09:14:22 +01:00
|
|
|
|
'';
|
2017-01-07 19:16:26 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
userName = mkOption {
|
2019-03-12 09:36:17 +01:00
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
|
default = null;
|
2023-07-02 01:45:18 +02:00
|
|
|
|
description = "Default user name to use.";
|
2017-01-07 19:16:26 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
userEmail = mkOption {
|
2019-03-12 09:36:17 +01:00
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
|
default = null;
|
2023-07-02 01:45:18 +02:00
|
|
|
|
description = "Default user email to use.";
|
2017-01-07 19:16:26 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
aliases = mkOption {
|
2019-02-01 01:06:18 +01:00
|
|
|
|
type = types.attrsOf types.str;
|
2020-02-02 00:39:17 +01:00
|
|
|
|
default = { };
|
2019-02-01 01:06:18 +01:00
|
|
|
|
example = { co = "checkout"; };
|
2023-07-02 01:45:18 +02:00
|
|
|
|
description = "Git aliases to define.";
|
2017-01-07 19:16:26 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
signing = mkOption {
|
|
|
|
|
type = types.nullOr signModule;
|
|
|
|
|
default = null;
|
2023-07-02 01:45:18 +02:00
|
|
|
|
description = "Options related to signing commits using GnuPG.";
|
2017-01-07 19:16:26 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extraConfig = mkOption {
|
2019-02-01 01:06:18 +01:00
|
|
|
|
type = types.either types.lines gitIniType;
|
2020-02-02 00:39:17 +01:00
|
|
|
|
default = { };
|
2019-02-01 01:06:18 +01:00
|
|
|
|
example = {
|
|
|
|
|
core = { whitespace = "trailing-space,space-before-tab"; };
|
2019-03-13 00:06:36 +01:00
|
|
|
|
url."ssh://git@host".insteadOf = "otherhost";
|
2019-02-01 01:06:18 +01:00
|
|
|
|
};
|
2023-07-02 01:45:18 +02:00
|
|
|
|
description = ''
|
2019-08-30 14:50:10 +02:00
|
|
|
|
Additional configuration to add. The use of string values is
|
|
|
|
|
deprecated and will be removed in the future.
|
|
|
|
|
'';
|
2017-01-07 19:16:26 +01:00
|
|
|
|
};
|
2017-09-21 14:45:20 +02:00
|
|
|
|
|
2022-09-04 18:57:45 +02:00
|
|
|
|
hooks = mkOption {
|
|
|
|
|
type = types.attrsOf types.path;
|
|
|
|
|
default = { };
|
|
|
|
|
example = literalExpression ''
|
|
|
|
|
{
|
|
|
|
|
pre-commit = ./pre-commit-script;
|
|
|
|
|
}
|
|
|
|
|
'';
|
2023-07-02 01:45:18 +02:00
|
|
|
|
description = ''
|
2022-09-04 18:57:45 +02:00
|
|
|
|
Configuration helper for Git hooks.
|
2023-07-01 01:30:13 +02:00
|
|
|
|
See <https://git-scm.com/docs/githooks>
|
2022-09-04 18:57:45 +02:00
|
|
|
|
for reference.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2017-09-21 14:45:20 +02:00
|
|
|
|
iniContent = mkOption {
|
2019-02-01 01:06:18 +01:00
|
|
|
|
type = gitIniType;
|
2017-09-21 14:45:20 +02:00
|
|
|
|
internal = true;
|
|
|
|
|
};
|
2017-11-12 13:28:12 +01:00
|
|
|
|
|
|
|
|
|
ignores = mkOption {
|
|
|
|
|
type = types.listOf types.str;
|
2020-02-02 00:39:17 +01:00
|
|
|
|
default = [ ];
|
2017-11-12 13:28:12 +01:00
|
|
|
|
example = [ "*~" "*.swp" ];
|
2023-07-02 01:45:18 +02:00
|
|
|
|
description = "List of paths that should be globally ignored.";
|
2017-11-12 13:28:12 +01:00
|
|
|
|
};
|
2018-04-18 23:41:20 +02:00
|
|
|
|
|
2019-09-24 11:20:00 +02:00
|
|
|
|
attributes = mkOption {
|
|
|
|
|
type = types.listOf types.str;
|
2020-02-02 00:39:17 +01:00
|
|
|
|
default = [ ];
|
2019-09-24 11:20:00 +02:00
|
|
|
|
example = [ "*.pdf diff=pdf" ];
|
2023-07-02 01:45:18 +02:00
|
|
|
|
description = "List of defining attributes set globally.";
|
2019-09-24 11:20:00 +02:00
|
|
|
|
};
|
|
|
|
|
|
2018-04-18 23:41:20 +02:00
|
|
|
|
includes = mkOption {
|
|
|
|
|
type = types.listOf includeModule;
|
2020-02-02 00:39:17 +01:00
|
|
|
|
default = [ ];
|
2021-10-09 11:14:08 +02:00
|
|
|
|
example = literalExpression ''
|
2018-04-18 23:41:20 +02:00
|
|
|
|
[
|
|
|
|
|
{ path = "~/path/to/config.inc"; }
|
|
|
|
|
{
|
|
|
|
|
path = "~/path/to/conditional.inc";
|
|
|
|
|
condition = "gitdir:~/src/dir";
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
'';
|
2023-07-02 01:45:18 +02:00
|
|
|
|
description = "List of configuration files to include.";
|
2018-04-18 23:41:20 +02:00
|
|
|
|
};
|
2019-02-03 23:54:29 +01:00
|
|
|
|
|
|
|
|
|
lfs = {
|
2023-07-02 01:45:18 +02:00
|
|
|
|
enable = mkEnableOption "Git Large File Storage";
|
2019-02-03 23:54:29 +01:00
|
|
|
|
|
|
|
|
|
skipSmudge = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = false;
|
2023-07-02 01:45:18 +02:00
|
|
|
|
description = ''
|
2019-02-03 23:54:29 +01:00
|
|
|
|
Skip automatic downloading of objects on clone or pull.
|
2023-07-01 01:30:13 +02:00
|
|
|
|
This requires a manual {command}`git lfs pull`
|
2019-02-03 23:54:29 +01:00
|
|
|
|
every time a new commit is checked out on your repository.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
};
|
2020-04-26 11:20:00 +02:00
|
|
|
|
|
2024-10-11 14:48:52 +02:00
|
|
|
|
maintenance = {
|
|
|
|
|
enable = mkEnableOption "" // {
|
|
|
|
|
description = ''
|
|
|
|
|
Enable the automatic {command}`git maintenance`.
|
|
|
|
|
|
|
|
|
|
See <https://git-scm.com/docs/git-maintenance>.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
repositories = mkOption {
|
|
|
|
|
type = with types; listOf str;
|
|
|
|
|
default = [ ];
|
|
|
|
|
description = ''
|
|
|
|
|
Repositories on which {command}`git maintenance` should run.
|
|
|
|
|
|
|
|
|
|
Should be a list of absolute paths.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
timers = mkOption {
|
|
|
|
|
type = types.attrsOf types.str;
|
|
|
|
|
default = {
|
|
|
|
|
hourly = "*-*-* 1..23:53:00";
|
|
|
|
|
daily = "Tue..Sun *-*-* 0:53:00";
|
|
|
|
|
weekly = "Mon 0:53:00";
|
|
|
|
|
};
|
|
|
|
|
description = ''
|
|
|
|
|
Systemd timers to create for scheduled {command}`git maintenance`.
|
|
|
|
|
|
|
|
|
|
Key is passed to `--schedule` argument in {command}`git maintenance run`
|
|
|
|
|
and value is passed to `Timer.OnCalendar` in `systemd.user.timers`.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2024-09-12 02:25:31 +02:00
|
|
|
|
diff-highlight = {
|
|
|
|
|
enable = mkEnableOption "" // {
|
|
|
|
|
description = ''
|
|
|
|
|
Enable the contrib {command}`diff-highlight` syntax highlighter.
|
|
|
|
|
See <https://github.com/git/git/blob/master/contrib/diff-highlight/README>,
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
pagerOpts = mkOption {
|
|
|
|
|
type = types.listOf types.str;
|
|
|
|
|
default = [ ];
|
|
|
|
|
example = [ "--tabs=4" "-RFX" ];
|
|
|
|
|
description = ''
|
|
|
|
|
Arguments to be passed to {command}`less`.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2022-04-04 16:53:29 +02:00
|
|
|
|
difftastic = {
|
2023-07-02 01:45:18 +02:00
|
|
|
|
enable = mkEnableOption "" // {
|
|
|
|
|
description = ''
|
2023-07-01 09:48:09 +02:00
|
|
|
|
Enable the {command}`difftastic` syntax highlighter.
|
|
|
|
|
See <https://github.com/Wilfred/difftastic>.
|
2022-04-04 16:53:29 +02:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2024-08-31 16:14:50 +02:00
|
|
|
|
package = mkPackageOption pkgs "difftastic" { };
|
|
|
|
|
|
2022-04-04 16:53:29 +02:00
|
|
|
|
background = mkOption {
|
|
|
|
|
type = types.enum [ "light" "dark" ];
|
|
|
|
|
default = "light";
|
|
|
|
|
example = "dark";
|
2023-07-02 01:45:18 +02:00
|
|
|
|
description = ''
|
2022-04-04 16:53:29 +02:00
|
|
|
|
Determines whether difftastic should use the lighter or darker colors
|
2022-12-03 05:20:00 +01:00
|
|
|
|
for syntax highlighting.
|
2022-04-04 16:53:29 +02:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
color = mkOption {
|
|
|
|
|
type = types.enum [ "always" "auto" "never" ];
|
|
|
|
|
default = "auto";
|
|
|
|
|
example = "always";
|
2023-07-02 01:45:18 +02:00
|
|
|
|
description = ''
|
2022-04-04 16:53:29 +02:00
|
|
|
|
Determines when difftastic should color its output.
|
|
|
|
|
'';
|
|
|
|
|
};
|
2022-07-08 19:26:09 +02:00
|
|
|
|
|
|
|
|
|
display = mkOption {
|
|
|
|
|
type =
|
|
|
|
|
types.enum [ "side-by-side" "side-by-side-show-both" "inline" ];
|
|
|
|
|
default = "side-by-side";
|
|
|
|
|
example = "inline";
|
2023-07-02 01:45:18 +02:00
|
|
|
|
description = ''
|
2022-07-08 19:26:09 +02:00
|
|
|
|
Determines how the output displays - in one column or two columns.
|
|
|
|
|
'';
|
|
|
|
|
};
|
2022-04-04 16:53:29 +02:00
|
|
|
|
};
|
|
|
|
|
|
2020-04-26 11:20:00 +02:00
|
|
|
|
delta = {
|
2023-07-02 01:45:18 +02:00
|
|
|
|
enable = mkEnableOption "" // {
|
|
|
|
|
description = ''
|
2023-07-01 09:48:09 +02:00
|
|
|
|
Whether to enable the {command}`delta` syntax highlighter.
|
|
|
|
|
See <https://github.com/dandavison/delta>.
|
2020-04-26 11:20:00 +02:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2023-07-02 01:45:18 +02:00
|
|
|
|
package = mkPackageOption pkgs "delta" { };
|
2023-04-20 06:41:38 +02:00
|
|
|
|
|
2020-04-26 11:20:00 +02:00
|
|
|
|
options = mkOption {
|
2020-07-20 17:03:40 +02: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";
|
|
|
|
|
};
|
|
|
|
|
};
|
2023-07-02 01:45:18 +02:00
|
|
|
|
description = ''
|
2020-07-20 17:03:40 +02:00
|
|
|
|
Options to configure delta.
|
2020-04-26 11:20:00 +02:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
};
|
2022-04-09 21:45:30 +02:00
|
|
|
|
|
|
|
|
|
diff-so-fancy = {
|
2023-07-02 01:45:18 +02:00
|
|
|
|
enable = mkEnableOption "" // {
|
|
|
|
|
description = ''
|
2023-07-01 09:48:09 +02:00
|
|
|
|
Enable the {command}`diff-so-fancy` diff colorizer.
|
|
|
|
|
See <https://github.com/so-fancy/diff-so-fancy>.
|
2022-04-09 21:45:30 +02:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2023-02-27 13:04:46 +01:00
|
|
|
|
pagerOpts = mkOption {
|
|
|
|
|
type = types.listOf types.str;
|
|
|
|
|
default = [ "--tabs=4" "-RFX" ];
|
2023-07-02 01:45:18 +02:00
|
|
|
|
description = ''
|
2023-07-01 01:30:13 +02:00
|
|
|
|
Arguments to be passed to {command}`less`.
|
2023-02-27 13:04:46 +01:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2022-04-09 21:45:30 +02:00
|
|
|
|
markEmptyLines = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = true;
|
|
|
|
|
example = false;
|
2023-07-02 01:45:18 +02:00
|
|
|
|
description = ''
|
2022-04-09 21:45:30 +02:00
|
|
|
|
Whether the first block of an empty line should be colored.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
changeHunkIndicators = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = true;
|
|
|
|
|
example = false;
|
2023-07-02 01:45:18 +02:00
|
|
|
|
description = ''
|
2022-04-09 21:45:30 +02:00
|
|
|
|
Simplify git header chunks to a more human readable format.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
stripLeadingSymbols = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = true;
|
|
|
|
|
example = false;
|
2023-07-02 01:45:18 +02:00
|
|
|
|
description = ''
|
2023-07-01 01:30:13 +02:00
|
|
|
|
Whether the `+` or `-` at
|
2022-04-09 21:45:30 +02:00
|
|
|
|
line-start should be removed.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
useUnicodeRuler = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = true;
|
|
|
|
|
example = false;
|
2023-07-02 01:45:18 +02:00
|
|
|
|
description = ''
|
2022-04-09 21:45:30 +02:00
|
|
|
|
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;
|
2023-07-02 01:45:18 +02:00
|
|
|
|
description = ''
|
2022-04-09 21:45:30 +02:00
|
|
|
|
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 19:16:26 +01:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2020-02-02 00:39:17 +01:00
|
|
|
|
config = mkIf cfg.enable (mkMerge [
|
|
|
|
|
{
|
|
|
|
|
home.packages = [ cfg.package ];
|
2022-04-04 16:53:29 +02:00
|
|
|
|
assertions = [{
|
2022-04-09 21:45:30 +02:00
|
|
|
|
assertion = let
|
2024-09-12 02:25:31 +02:00
|
|
|
|
enabled = [
|
|
|
|
|
cfg.delta.enable
|
|
|
|
|
cfg.diff-so-fancy.enable
|
|
|
|
|
cfg.difftastic.enable
|
|
|
|
|
cfg.diff-highlight.enable
|
|
|
|
|
];
|
2022-04-09 21:45:30 +02:00
|
|
|
|
in count id enabled <= 1;
|
2022-04-04 16:53:29 +02:00
|
|
|
|
message =
|
2024-09-12 02:25:31 +02:00
|
|
|
|
"Only one of 'programs.git.delta.enable' or 'programs.git.difftastic.enable' or 'programs.git.diff-so-fancy.enable' or 'programs.git.diff-highlight' can be set to true at the same time.";
|
2022-04-04 16:53:29 +02:00
|
|
|
|
}];
|
2017-09-21 14:45:20 +02:00
|
|
|
|
|
2020-02-02 00:39:17 +01:00
|
|
|
|
programs.git.iniContent.user = {
|
|
|
|
|
name = mkIf (cfg.userName != null) cfg.userName;
|
|
|
|
|
email = mkIf (cfg.userEmail != null) cfg.userEmail;
|
|
|
|
|
};
|
2017-01-07 19:16:26 +01:00
|
|
|
|
|
2020-02-02 00:39:17 +01:00
|
|
|
|
xdg.configFile = {
|
2023-08-21 09:35:43 +02:00
|
|
|
|
"git/config".text = generators.toGitINI cfg.iniContent;
|
2017-11-12 13:28:12 +01:00
|
|
|
|
|
2020-02-02 00:39:17 +01:00
|
|
|
|
"git/ignore" = mkIf (cfg.ignores != [ ]) {
|
|
|
|
|
text = concatStringsSep "\n" cfg.ignores + "\n";
|
|
|
|
|
};
|
2019-09-24 11:20:00 +02:00
|
|
|
|
|
2020-02-02 00:39:17 +01:00
|
|
|
|
"git/attributes" = mkIf (cfg.attributes != [ ]) {
|
|
|
|
|
text = concatStringsSep "\n" cfg.attributes + "\n";
|
2017-11-12 13:28:12 +01:00
|
|
|
|
};
|
2020-02-02 00:39:17 +01:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
programs.git.iniContent = let
|
|
|
|
|
hasSmtp = name: account: account.smtp != null;
|
|
|
|
|
|
|
|
|
|
genIdentity = name: account:
|
|
|
|
|
with account;
|
2021-02-28 16:06:11 +01:00
|
|
|
|
nameValuePair "sendemail.${name}" (if account.msmtp.enable then {
|
|
|
|
|
smtpServer = "${pkgs.msmtp}/bin/msmtp";
|
2021-02-28 20:42:44 +01:00
|
|
|
|
envelopeSender = "auto";
|
2024-05-06 08:17:53 +02:00
|
|
|
|
from = "${realName} <${address}>";
|
2021-02-28 16:06:11 +01: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 20:23:50 +02:00
|
|
|
|
smtpSslCertPath =
|
|
|
|
|
mkIf smtp.tls.enable (toString smtp.tls.certificatesFile);
|
2021-02-28 16:06:11 +01:00
|
|
|
|
smtpServer = smtp.host;
|
|
|
|
|
smtpUser = userName;
|
2024-05-06 08:17:53 +02:00
|
|
|
|
from = "${realName} <${address}>";
|
2021-02-28 16:06:11 +01:00
|
|
|
|
} // optionalAttrs (smtp.port != null) {
|
|
|
|
|
smtpServerPort = smtp.port;
|
|
|
|
|
});
|
2020-02-02 00:39:17 +01:00
|
|
|
|
in mapAttrs' genIdentity
|
|
|
|
|
(filterAttrs hasSmtp config.accounts.email.accounts);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
(mkIf (cfg.signing != null) {
|
|
|
|
|
programs.git.iniContent = {
|
2021-04-05 14:28:36 +02:00
|
|
|
|
user.signingKey = mkIf (cfg.signing.key != null) cfg.signing.key;
|
2023-03-02 12:27:57 +01:00
|
|
|
|
commit.gpgSign = mkDefault cfg.signing.signByDefault;
|
|
|
|
|
tag.gpgSign = mkDefault cfg.signing.signByDefault;
|
2020-02-02 00:39:17 +01:00
|
|
|
|
gpg.program = cfg.signing.gpgPath;
|
|
|
|
|
};
|
|
|
|
|
})
|
|
|
|
|
|
2022-09-04 18:57:45 +02: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-02 00:39:17 +01: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}";
|
|
|
|
|
};
|
2023-08-21 09:35:43 +02:00
|
|
|
|
in mkAfter (concatStringsSep "\n"
|
|
|
|
|
(map generators.toGitINI (map include cfg.includes)));
|
2020-02-02 00:39:17 +01:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
(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 14:45:20 +02:00
|
|
|
|
};
|
2020-02-02 00:39:17 +01:00
|
|
|
|
})
|
2020-04-26 11:20:00 +02:00
|
|
|
|
|
2024-10-11 14:48:52 +02:00
|
|
|
|
(mkIf cfg.maintenance.enable {
|
|
|
|
|
programs.git.iniContent.maintenance.repo = cfg.maintenance.repositories;
|
|
|
|
|
|
|
|
|
|
systemd.user.services."git-maintenance@" = {
|
|
|
|
|
Unit = {
|
|
|
|
|
Description = "Optimize Git repositories data";
|
|
|
|
|
Documentation = [ "man:git-maintenance(1)" ];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Service = {
|
|
|
|
|
Type = "oneshot";
|
|
|
|
|
ExecStart = let exe = lib.getExe cfg.package;
|
|
|
|
|
in ''
|
|
|
|
|
"${exe}" --exec-path="${exe}" for-each-repo --config=maintenance.repo maintenance run --schedule=%i
|
|
|
|
|
'';
|
|
|
|
|
LockPersonality = "yes";
|
|
|
|
|
MemoryDenyWriteExecute = "yes";
|
|
|
|
|
NoNewPrivileges = "yes";
|
|
|
|
|
RestrictAddressFamilies = "AF_UNIX AF_INET AF_INET6 AF_VSOCK";
|
|
|
|
|
RestrictNamespaces = "yes";
|
|
|
|
|
RestrictRealtime = "yes";
|
|
|
|
|
RestrictSUIDSGID = "yes";
|
|
|
|
|
SystemCallArchitectures = "native";
|
|
|
|
|
SystemCallFilter = "@system-service";
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
systemd.user.timers = let
|
|
|
|
|
toSystemdTimer = name: time:
|
|
|
|
|
lib.attrsets.nameValuePair "git-maintenance@${name}" {
|
|
|
|
|
Unit.Description = "Optimize Git repositories data";
|
|
|
|
|
|
|
|
|
|
Timer = {
|
|
|
|
|
OnCalendar = time;
|
|
|
|
|
Persistent = true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Install.WantedBy = [ "timers.target" ];
|
|
|
|
|
};
|
|
|
|
|
in lib.attrsets.mapAttrs' toSystemdTimer cfg.maintenance.timers;
|
|
|
|
|
})
|
|
|
|
|
|
2024-09-12 02:25:31 +02:00
|
|
|
|
(mkIf cfg.diff-highlight.enable {
|
|
|
|
|
programs.git.iniContent = let
|
|
|
|
|
dhCommand =
|
|
|
|
|
"${cfg.package}/share/git/contrib/diff-highlight/diff-highlight";
|
|
|
|
|
in {
|
|
|
|
|
core.pager = "${dhCommand} | ${getExe pkgs.less} ${
|
|
|
|
|
escapeShellArgs cfg.diff-highlight.pagerOpts
|
|
|
|
|
}";
|
|
|
|
|
interactive.diffFilter = dhCommand;
|
|
|
|
|
};
|
|
|
|
|
})
|
|
|
|
|
|
2022-04-04 16:53:29 +02:00
|
|
|
|
(mkIf cfg.difftastic.enable {
|
2024-08-31 16:14:50 +02:00
|
|
|
|
home.packages = [ cfg.difftastic.package ];
|
2022-04-04 16:53:29 +02:00
|
|
|
|
|
|
|
|
|
programs.git.iniContent = let
|
2022-07-08 19:26:09 +02:00
|
|
|
|
difftCommand = concatStringsSep " " [
|
2024-08-31 16:14:50 +02:00
|
|
|
|
"${getExe cfg.difftastic.package}"
|
2022-07-08 19:26:09 +02:00
|
|
|
|
"--color ${cfg.difftastic.color}"
|
|
|
|
|
"--background ${cfg.difftastic.background}"
|
|
|
|
|
"--display ${cfg.difftastic.display}"
|
|
|
|
|
];
|
2023-02-02 02:58:17 +01:00
|
|
|
|
in { diff.external = difftCommand; };
|
2022-04-04 16:53:29 +02:00
|
|
|
|
})
|
|
|
|
|
|
2023-04-20 06:41:38 +02:00
|
|
|
|
(let
|
|
|
|
|
deltaPackage = cfg.delta.package;
|
|
|
|
|
deltaCommand = "${deltaPackage}/bin/delta";
|
|
|
|
|
in mkIf cfg.delta.enable {
|
|
|
|
|
home.packages = [ deltaPackage ];
|
2021-03-18 23:32:50 +01:00
|
|
|
|
|
2023-04-20 06:41:38 +02:00
|
|
|
|
programs.git.iniContent = {
|
2021-01-20 18:58:17 +01:00
|
|
|
|
core.pager = deltaCommand;
|
|
|
|
|
interactive.diffFilter = "${deltaCommand} --color-only";
|
|
|
|
|
delta = cfg.delta.options;
|
|
|
|
|
};
|
2020-04-26 11:20:00 +02:00
|
|
|
|
})
|
2022-04-09 21:45:30 +02: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 13:04:46 +01:00
|
|
|
|
core.pager = "${dsfCommand} | ${pkgs.less}/bin/less ${
|
|
|
|
|
escapeShellArgs cfg.diff-so-fancy.pagerOpts
|
|
|
|
|
}";
|
2022-04-09 21:45:30 +02: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-02 00:39:17 +01:00
|
|
|
|
]);
|
2017-01-07 19:16:26 +01:00
|
|
|
|
}
|