mirror of
https://github.com/nix-community/home-manager
synced 2024-11-27 05:29:46 +01:00
programs.git: make signing key id be optional (#1886)
* Git: Make signing key id be optional Thus by default the signing key is selected by commit’s author. * Git: Add tests for config with and without signing key id * Git: Format tests for signing key * Git: Remove default value (null) for signing key * Git: Update description for signing key
This commit is contained in:
parent
25a6a6d298
commit
cc60c22c69
6 changed files with 73 additions and 3 deletions
|
@ -61,8 +61,13 @@ let
|
||||||
signModule = types.submodule {
|
signModule = types.submodule {
|
||||||
options = {
|
options = {
|
||||||
key = mkOption {
|
key = mkOption {
|
||||||
type = types.str;
|
type = types.nullOr types.str;
|
||||||
description = "The default GPG signing key fingerprint.";
|
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.
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
signByDefault = mkOption {
|
signByDefault = mkOption {
|
||||||
|
@ -303,7 +308,7 @@ in {
|
||||||
|
|
||||||
(mkIf (cfg.signing != null) {
|
(mkIf (cfg.signing != null) {
|
||||||
programs.git.iniContent = {
|
programs.git.iniContent = {
|
||||||
user.signingKey = cfg.signing.key;
|
user.signingKey = mkIf (cfg.signing.key != null) cfg.signing.key;
|
||||||
commit.gpgSign = cfg.signing.signByDefault;
|
commit.gpgSign = cfg.signing.signByDefault;
|
||||||
gpg.program = cfg.signing.gpgPath;
|
gpg.program = cfg.signing.gpgPath;
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,4 +3,6 @@
|
||||||
git-with-most-options = ./git.nix;
|
git-with-most-options = ./git.nix;
|
||||||
git-with-msmtp = ./git-with-msmtp.nix;
|
git-with-msmtp = ./git-with-msmtp.nix;
|
||||||
git-with-str-extra-config = ./git-with-str-extra-config.nix;
|
git-with-str-extra-config = ./git-with-str-extra-config.nix;
|
||||||
|
git-with-signing-key-id = ./git-with-signing-key-id.nix;
|
||||||
|
git-without-signing-key-id = ./git-without-signing-key-id.nix;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
[commit]
|
||||||
|
gpgSign = true
|
||||||
|
|
||||||
|
[gpg]
|
||||||
|
program = "path-to-gpg"
|
||||||
|
|
||||||
|
[user]
|
||||||
|
email = "user@example.org"
|
||||||
|
name = "John Doe"
|
||||||
|
signingKey = "00112233445566778899AABBCCDDEEFF"
|
22
tests/modules/programs/git/git-with-signing-key-id.nix
Normal file
22
tests/modules/programs/git/git-with-signing-key-id.nix
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
{ pkgs, ... }: {
|
||||||
|
config = {
|
||||||
|
programs.git = {
|
||||||
|
enable = true;
|
||||||
|
userName = "John Doe";
|
||||||
|
userEmail = "user@example.org";
|
||||||
|
|
||||||
|
signing = {
|
||||||
|
gpgPath = "path-to-gpg";
|
||||||
|
key = "00112233445566778899AABBCCDDEEFF";
|
||||||
|
signByDefault = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists home-files/.config/git/config
|
||||||
|
assertFileContent home-files/.config/git/config ${
|
||||||
|
./git-with-signing-key-id-expected.conf
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
[commit]
|
||||||
|
gpgSign = true
|
||||||
|
|
||||||
|
[gpg]
|
||||||
|
program = "path-to-gpg"
|
||||||
|
|
||||||
|
[user]
|
||||||
|
email = "user@example.org"
|
||||||
|
name = "John Doe"
|
22
tests/modules/programs/git/git-without-signing-key-id.nix
Normal file
22
tests/modules/programs/git/git-without-signing-key-id.nix
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
{ pkgs, ... }: {
|
||||||
|
config = {
|
||||||
|
programs.git = {
|
||||||
|
enable = true;
|
||||||
|
userName = "John Doe";
|
||||||
|
userEmail = "user@example.org";
|
||||||
|
|
||||||
|
signing = {
|
||||||
|
gpgPath = "path-to-gpg";
|
||||||
|
key = null;
|
||||||
|
signByDefault = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists home-files/.config/git/config
|
||||||
|
assertFileContent home-files/.config/git/config ${
|
||||||
|
./git-without-signing-key-id-expected.conf
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue