From 12a61ac0938cd0f883a7d69105e9d11bb58c4f32 Mon Sep 17 00:00:00 2001 From: Jan-Bulthuis Date: Fri, 30 Oct 2026 20:10:29 +0100 Subject: [PATCH] feat: git commit signing --- modules/home/development/git.nix | 22 ++++++++++++++++++++++ profiles/home/jan.nix | 4 ++++ 2 files changed, 26 insertions(+) diff --git a/modules/home/development/git.nix b/modules/home/development/git.nix index bdb6a81..eb1b5aa 100644 --- a/modules/home/development/git.nix +++ b/modules/home/development/git.nix @@ -28,6 +28,18 @@ in default = [ ]; description = "Paths to globally ignore"; }; + + signingKey = mkOption { + type = types.nullOr types.str; + default = null; + description = "Path to the SSH public key used to sign commits and tags."; + }; + + allowedSigners = mkOption { + type = types.listOf types.str; + default = [ ]; + description = "Trusted signers for verifying SSH signatures, as \" \" lines."; + }; }; config = mkIf cfg.enable { @@ -48,6 +60,16 @@ in settings.user.name = cfg.user; settings.user.email = cfg.email; ignores = cfg.ignores; + + signing = mkIf (cfg.signingKey != null) { + format = "ssh"; + key = cfg.signingKey; + signByDefault = true; # commit.gpgsign and tag.gpgSign + }; + + settings.gpg.ssh.allowedSignersFile = mkIf (cfg.allowedSigners != [ ]) ( + toString (pkgs.writeText "git-allowed-signers" (concatLines cfg.allowedSigners)) + ); }; }; } diff --git a/profiles/home/jan.nix b/profiles/home/jan.nix index 3290866..69378c1 100644 --- a/profiles/home/jan.nix +++ b/profiles/home/jan.nix @@ -264,6 +264,10 @@ in enable = true; user = "Jan-Bulthuis"; email = "git@bulthuis.dev"; + signingKey = "${config.home.homeDirectory}/.ssh/id_ed25519.pub"; + allowedSigners = [ + "git@bulthuis.dev ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKKxoQSxfYqf9ITN8Fhckk8WbY4dwtBAXOhC9jxihJvq" + ]; # TODO: Move ignores = [ ".envrc"