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

View File

@ -1,12 +1,13 @@
{
config,
gpgSigningKey,
lib,
pkgs,
profile,
...
}:
with lib;
let gpgCfg = config.modules.gpg;
in
{
imports = [
../../modules/homes
@ -34,7 +35,7 @@ with lib;
name = "Joshua Yuen";
email = "joshuayuen99@gmail.com";
# 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;
init.defaultBranch = "main";

View File

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

View File

@ -25,6 +25,11 @@ in
programs = {
gpg = {
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 {
type = types.str;
default = "";
type = types.nullOr types.str;
default = null;
description = "The key ID to sign with for git";
};
};