From 20888204fc0a149631af12111cb58f782134acbe Mon Sep 17 00:00:00 2001 From: Jeremy Stucki Date: Wed, 6 Nov 2024 11:28:58 +0100 Subject: [PATCH] Make commit signing work on darwin --- common/nixos-home-manager.nix | 18 ------------------ components/git.nix | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/common/nixos-home-manager.nix b/common/nixos-home-manager.nix index 803d7cc..1947226 100644 --- a/common/nixos-home-manager.nix +++ b/common/nixos-home-manager.nix @@ -1,8 +1,5 @@ { pkgs, ... }: -let - publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIG9keparNqpev2qrDO3cAiDzyTUsAAN9Mh+JLbOsdiZs"; -in { imports = map (x: ../components + x) [ /common-apps.nix @@ -11,19 +8,4 @@ in ]; home.homeDirectory = "/home/jeremy"; - - programs.git.extraConfig = { - commit.gpgsign = true; - user.signingkey = publicKey; - "gpg \"ssh\"".program = "${pkgs._1password-gui}/bin/op-ssh-sign"; - - gpg = { - format = "ssh"; - ssh.allowedSignersFile = builtins.toFile "allowed_signers" '' - dev@jeremystucki.ch ${publicKey} - jeremy.stucki@valora.com ${publicKey} - jeremy.stucki@ost.ch ${publicKey} - ''; - }; - }; } diff --git a/components/git.nix b/components/git.nix index c93e084..4954b95 100644 --- a/components/git.nix +++ b/components/git.nix @@ -2,6 +2,7 @@ let gitPackage = pkgs.git; + publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIG9keparNqpev2qrDO3cAiDzyTUsAAN9Mh+JLbOsdiZs"; in { home.shellAliases = { @@ -58,6 +59,24 @@ in autosquash = true; updateRefs = true; }; + + commit.gpgsign = true; + user.signingkey = publicKey; + + "gpg \"ssh\"".program = + if pkgs.stdenv.isDarwin then + "/Applications/1Password.app/Contents/MacOS/op-ssh-sig" + else + "${pkgs._1password-gui}/bin/op-ssh-sign"; + + gpg = { + format = "ssh"; + ssh.allowedSignersFile = builtins.toFile "allowed_signers" '' + dev@jeremystucki.ch ${publicKey} + jeremy.stucki@valora.com ${publicKey} + jeremy.stucki@ost.ch ${publicKey} + ''; + }; }; delta = {