Skip to content

Commit 76204e2

Browse files
committed
git: actually fix things
I'm bad at Nix, apparently
1 parent 3ce3526 commit 76204e2

File tree

4 files changed

+16
-25
lines changed

4 files changed

+16
-25
lines changed

format

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#! /usr/bin/env nix-shell
2-
#! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/6616de389ed55fba6eeba60377fc04732d5a207c.tar.gz -i bash -p git gnugrep gnused findutils nixfmt
2+
#! nix-shell -i bash -p git gnugrep gnused findutils nixfmt
3+
#1 nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/6616de389ed55fba6eeba60377fc04732d5a207c.tar.gz -i bash -p git gnugrep gnused findutils nixfmt
34

45
nixfmt_args=()
56
files=()

modules/programs/git.nix

+9-18
Original file line numberDiff line numberDiff line change
@@ -489,28 +489,19 @@ in {
489489
}
490490

491491
(mkIf (cfg.signing != null) {
492-
programs.git.iniContent = with cfg.signing;
492+
programs.git.iniContent = with cfg;
493493
let
494-
formats = [
495-
{
496-
format = "openpgp";
497-
defaultProgram = "${pkgs.gnupg}/bin/gpg2";
498-
}
499-
{
500-
format = "ssh";
501-
defaultProgram = "${pkgs.openssh}/bin/ssh";
502-
}
503-
{
504-
format = "x509";
505-
defaultProgram = "${pkgs.gnupg}/bin/gpgsm";
506-
}
507-
];
494+
formats = {
495+
openpgp = "${pkgs.gnupg}/bin/gpg2";
496+
ssh = "${pkgs.openssh}/bin/ssh";
497+
x509 = "${pkgs.gnupg}/bin/gpgsm";
498+
};
508499
in {
509500
gpg = {
510501
format = mkIf (signing.format != null) signing.format;
511-
} // lib.genAttrs formats ({ format, defaultProgram, }: {
512-
program =
513-
mkIf (signing.format == f) signing.program or defaultProgram;
502+
} // lib.genAttrs (builtins.attrNames formats) (f: {
503+
program = mkIf (signing.format == f)
504+
signing.program or (builtins.getAttr f);
514505
});
515506

516507
user.signingKey = mkIf (signing.key != null) signing.key;

tests/modules/programs/git/git-with-signing-key-id-legacy-expected.conf

-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
[commit]
22
gpgSign = true
33

4-
[gpg]
5-
format = "openpgp"
6-
7-
[gpg "openpgp"]
8-
program = "path-to-gpg"
9-
104
[tag]
115
gpgSign = true
126

tests/modules/programs/git/git-with-signing-key-id-legacy.nix

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
{ pkgs, ... }: {
22
config = {
3+
test.asserts.warnings.expected = [''
4+
`programs.git.signing.gpgPath` has been deprecated.
5+
Please use `programs.git.signing.program` instead.
6+
''];
7+
38
programs.git = {
49
enable = true;
510
userName = "John Doe";

0 commit comments

Comments
 (0)