Add GPG config for git signing

This commit is contained in:
Joshua Yuen 2026-06-20 23:25:48 -04:00
parent f5e578c184
commit 50b6262b06
Signed by: josh
GPG Key ID: 530DA0331EFE99F5
8 changed files with 74 additions and 3 deletions

View File

@ -58,7 +58,6 @@
host = "laptop";
profile = "desktop";
username = "josh";
gpgSigningKey = "0x530DA0331EFE99F5";
in nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = {
@ -66,7 +65,6 @@
inherit host;
inherit profile;
inherit username;
inherit gpgSigningKey;
};
pkgs = pkgs;
modules = [
@ -103,7 +101,6 @@
inherit host;
inherit profile;
inherit username;
};
pkgs = pkgs;
modules = [

View File

@ -1,4 +1,6 @@
{
config,
gpgSigningKey,
lib,
pkgs,
profile,
@ -25,6 +27,23 @@ with lib;
];
};
programs.git = {
enable = true;
settings = {
user = {
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;
};
commit.gpgsign = true;
init.defaultBranch = "main";
};
};
# Enable GPG-agent for git signing
modules.gpg.enable = true;
# Let Home Manager install and manage itself
programs.home-manager.enable = true;

View File

@ -12,4 +12,6 @@
./hardware.nix
./host-packages.nix
];
modules.gpg.signingKey = "0x530DA0331EFE99F5";
}

View File

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

View File

@ -5,6 +5,7 @@
imports = [
./direnv.nix
./firefox.nix
./gpg.nix
./fzf.nix
./hyprland
./kitty.nix

31
modules/homes/gpg.nix Normal file
View File

@ -0,0 +1,31 @@
{
config,
lib,
pkgs,
...
}:
with lib;
let
cfg = config.modules.gpg;
in
{
config = mkIf cfg.enable {
services = {
gpg-agent = {
enable = true;
enableSshSupport = true;
enableBashIntegration = true;
enableZshIntegration = true;
pinentry.package = pkgs.pinentry-qt;
};
};
home.packages = [ pkgs.gnupg ];
programs = {
gpg = {
enable = true;
};
};
};
}

View File

@ -4,6 +4,7 @@
{
imports = [
./displayManager.nix
./gpg.nix
./hyprland.nix
./localsend.nix
./pipewire.nix

19
modules/options/gpg.nix Normal file
View File

@ -0,0 +1,19 @@
{
lib,
...
}:
with lib;
{
options.modules.gpg = {
enable = mkEnableOption {
default = false;
description = "Enable gpg-agent";
};
signingKey = mkOption {
type = types.str;
default = "";
description = "The key ID to sign with for git";
};
};
}