1
0
mirror of https://github.com/nix-community/home-manager synced 2024-06-13 10:13:39 +02:00

Backport “Make Git signing key id be optional” to “release-20.09” (#1903)

This commit is contained in:
Viacheslav Lotsmanov 2021-04-07 22:46:34 +03:00 committed by GitHub
parent a36c4fe973
commit 2aa20ae969
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 73 additions and 3 deletions

View File

@ -61,8 +61,13 @@ let
signModule = types.submodule {
options = {
key = mkOption {
type = types.str;
description = "The default GPG signing key fingerprint.";
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 commits author.
'';
};
signByDefault = mkOption {
@ -297,7 +302,7 @@ in {
(mkIf (cfg.signing != null) {
programs.git.iniContent = {
user.signingKey = cfg.signing.key;
user.signingKey = mkIf (cfg.signing.key != null) cfg.signing.key;
commit.gpgSign = cfg.signing.signByDefault;
gpg.program = cfg.signing.gpgPath;
};

View File

@ -2,4 +2,6 @@
git-with-email = ./git-with-email.nix;
git-with-most-options = ./git.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;
}

View File

@ -0,0 +1,10 @@
[commit]
gpgSign = true
[gpg]
program = "path-to-gpg"
[user]
email = "user@example.org"
name = "John Doe"
signingKey = "00112233445566778899AABBCCDDEEFF"

View 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
}
'';
};
}

View File

@ -0,0 +1,9 @@
[commit]
gpgSign = true
[gpg]
program = "path-to-gpg"
[user]
email = "user@example.org"
name = "John Doe"

View 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
}
'';
};
}