1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00

git: reorganize

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
Austin Horstman 2025-10-16 21:46:02 -05:00
parent 7522ba8a0c
commit bb7bb23583

View file

@ -13,12 +13,19 @@ let
mkIf mkIf
mkOption mkOption
mkOptionDefault mkOptionDefault
mkPackageOption
types types
; ;
cfg = config.programs.git; cfg = config.programs.git;
in
{
meta.maintainers = with lib.maintainers; [
khaneliman
rycee
];
options =
let
gitIniType = gitIniType =
with types; with types;
let let
@ -28,76 +35,8 @@ let
supersectionType = attrsOf (either multipleType sectionType); supersectionType = attrsOf (either multipleType sectionType);
in in
attrsOf supersectionType; attrsOf supersectionType;
in
includeModule = types.submodule (
{ config, ... }:
{ {
options = {
condition = mkOption {
type = types.nullOr types.str;
default = null;
description = ''
Include this configuration only when {var}`condition`
matches. Allowed conditions are described in
{manpage}`git-config(1)`.
'';
};
path = mkOption {
type = with types; either str path;
description = "Path of the configuration file to include.";
};
contents = mkOption {
type = types.attrsOf types.anything;
default = { };
example = literalExpression ''
{
user = {
email = "bob@work.example.com";
name = "Bob Work";
signingKey = "1A2B3C4D5E6F7G8H";
};
commit = {
gpgSign = true;
};
};
'';
description = ''
Configuration to include. If empty then a path must be given.
This follows the configuration structure as described in
{manpage}`git-config(1)`.
'';
};
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 (lib.hm.strings.storeFileName config.contentSuffix) (
lib.generators.toGitINI config.contents
)
)
);
}
);
in
{
meta.maintainers = with lib.maintainers; [
khaneliman
rycee
];
options = {
programs.git = { programs.git = {
enable = mkEnableOption "Git"; enable = mkEnableOption "Git";
@ -225,7 +164,69 @@ in
}; };
includes = mkOption { includes = mkOption {
type = types.listOf includeModule; type = types.listOf (
types.submodule (
{ config, ... }:
{
options = {
condition = mkOption {
type = types.nullOr types.str;
default = null;
description = ''
Include this configuration only when {var}`condition`
matches. Allowed conditions are described in
{manpage}`git-config(1)`.
'';
};
path = mkOption {
type = with types; either str path;
description = "Path of the configuration file to include.";
};
contents = mkOption {
type = types.attrsOf types.anything;
default = { };
example = literalExpression ''
{
user = {
email = "bob@work.example.com";
name = "Bob Work";
signingKey = "1A2B3C4D5E6F7G8H";
};
commit = {
gpgSign = true;
};
};
'';
description = ''
Configuration to include. If empty then a path must be given.
This follows the configuration structure as described in
{manpage}`git-config(1)`.
'';
};
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 (lib.hm.strings.storeFileName config.contentSuffix) (
lib.generators.toGitINI config.contents
)
)
);
}
)
);
default = [ ]; default = [ ];
example = literalExpression '' example = literalExpression ''
[ [
@ -292,7 +293,6 @@ in
''; '';
}; };
}; };
}; };
}; };
@ -352,7 +352,7 @@ in
{ {
programs.git.iniContent = programs.git.iniContent =
let let
hasSmtp = name: account: account.enable && account.smtp != null; hasSmtp = _name: account: account.enable && account.smtp != null;
genIdentity = genIdentity =
name: account: name: account:
@ -600,7 +600,6 @@ in
}; };
}; };
}) })
] ]
); );
} }