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:
parent
7522ba8a0c
commit
bb7bb23583
1 changed files with 255 additions and 256 deletions
|
|
@ -13,12 +13,19 @@ let
|
|||
mkIf
|
||||
mkOption
|
||||
mkOptionDefault
|
||||
mkPackageOption
|
||||
types
|
||||
;
|
||||
|
||||
cfg = config.programs.git;
|
||||
in
|
||||
{
|
||||
meta.maintainers = with lib.maintainers; [
|
||||
khaneliman
|
||||
rycee
|
||||
];
|
||||
|
||||
options =
|
||||
let
|
||||
gitIniType =
|
||||
with types;
|
||||
let
|
||||
|
|
@ -28,76 +35,8 @@ let
|
|||
supersectionType = attrsOf (either multipleType sectionType);
|
||||
in
|
||||
attrsOf supersectionType;
|
||||
|
||||
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 = {
|
||||
enable = mkEnableOption "Git";
|
||||
|
||||
|
|
@ -225,7 +164,69 @@ in
|
|||
};
|
||||
|
||||
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 = [ ];
|
||||
example = literalExpression ''
|
||||
[
|
||||
|
|
@ -292,7 +293,6 @@ in
|
|||
'';
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
|
|
@ -352,7 +352,7 @@ in
|
|||
{
|
||||
programs.git.iniContent =
|
||||
let
|
||||
hasSmtp = name: account: account.enable && account.smtp != null;
|
||||
hasSmtp = _name: account: account.enable && account.smtp != null;
|
||||
|
||||
genIdentity =
|
||||
name: account:
|
||||
|
|
@ -600,7 +600,6 @@ in
|
|||
};
|
||||
};
|
||||
})
|
||||
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue