Add your signing key as the GPG default and trusted key list

This commit is contained in:
Joshua Yuen 2026-06-21 12:51:31 -04:00
parent 006713adc7
commit 78c85b1590
Signed by: josh
GPG Key ID: 530DA0331EFE99F5
5 changed files with 15 additions and 5 deletions

View File

@ -115,6 +115,7 @@
homeConfigurations.josh = let homeConfigurations.josh = let
profile = "desktop"; profile = "desktop";
username = "josh"; username = "josh";
gpgSigningKey = null;
in home-manager.lib.homeManagerConfiguration { in home-manager.lib.homeManagerConfiguration {
extraSpecialArgs = { extraSpecialArgs = {
inherit inputs; inherit inputs;
@ -123,6 +124,9 @@
}; };
pkgs = pkgs; pkgs = pkgs;
modules = [ modules = [
{
modules.gpg.signingKey = gpgSigningKey;
}
./homes/josh/home.nix ./homes/josh/home.nix
stylix.homeModules.stylix stylix.homeModules.stylix
]; ];

View File

@ -1,12 +1,13 @@
{ {
config, config,
gpgSigningKey,
lib, lib,
pkgs, pkgs,
profile, profile,
... ...
}: }:
with lib; with lib;
let gpgCfg = config.modules.gpg;
in
{ {
imports = [ imports = [
../../modules/homes ../../modules/homes
@ -34,7 +35,7 @@ with lib;
name = "Joshua Yuen"; name = "Joshua Yuen";
email = "joshuayuen99@gmail.com"; email = "joshuayuen99@gmail.com";
# We need to do this to pass through the (optional) signing key from the hosts/* file # We need to do this to pass through the (optional) signing key from the hosts/* file
signingkey = if gpgSigningKey != "" then gpgSigningKey else config.modules.gpg.signingKey; signingkey = mkIf (gpgCfg.signingKey != null) gpgCfg.signingKey;
}; };
commit.gpgsign = true; commit.gpgsign = true;
init.defaultBranch = "main"; init.defaultBranch = "main";

View File

@ -24,10 +24,10 @@ in
profile profile
username username
; ;
gpgSigningKey = config.modules.gpg.signingKey;
}; };
users.${username} = { users.${username} = {
imports = [ ../../homes/${username}/home.nix ]; imports = [ ../../homes/${username}/home.nix ];
modules.gpg.signingKey = config.modules.gpg.signingKey;
}; };
}; };

View File

@ -25,6 +25,11 @@ in
programs = { programs = {
gpg = { gpg = {
enable = true; enable = true;
settings = {
default-key = mkIf (cfg.signingKey != null) cfg.signingKey;
trusted-key = mkIf (cfg.signingKey != null) cfg.signingKey;
};
}; };
}; };
}; };

View File

@ -11,8 +11,8 @@ with lib;
}; };
signingKey = mkOption { signingKey = mkOption {
type = types.str; type = types.nullOr types.str;
default = ""; default = null;
description = "The key ID to sign with for git"; description = "The key ID to sign with for git";
}; };
}; };