aleeusgr / nix-things

a toolbox
1 stars 0 forks source link

fix git commit signing #88

Open aleeusgr opened 2 months ago

aleeusgr commented 2 months ago

I need to sign my commits: https://github.com/IntersectMBO/cardano-node/pull/5959

How to do this?

  1. install gnupg
  2. create a key
  3. tell git about the key
  4. set up commit signing
  5. git log --format=raw to see if the commits are signed.
aleeusgr commented 2 months ago

on nixOS these settings may be managed with home-manager

https://nix-community.github.io/home-manager/options.xhtml#opt-programs.git.signing

aleeusgr commented 2 months ago

https://discourse.nixos.org/t/nixos-home-manager-program-git-error-gpg-failed-to-sign-the-data/8533/5 https://discourse.nixos.org/t/how-to-full-git-setup-in-home-manager-or-else/24861

aleeusgr commented 2 months ago
  1. install gpg and attemt to generate the key: gpg --full-generate-key

gpg: agent_genkey failed: No pinentry

https://superuser.com/questions/1628782/gpg-signing-failed-no-pinentry

add pinentry:

nixos-rebuild

error: access to absolute path '/home/alex/.ssh/id_ed25519.pub' is forbidden in pure eval mode (use '--impure' to override)

remove the line, switch, reboot.

error repeats.

fixed: https://github.com/aleeusgr/nix-things/commit/bb38bdd85abe4f08026f14fcd25348ea6f4fb65a

doc:

https://jeppesen.io/git-commit-sign-nix-home-manager-ssh/

aleeusgr commented 2 months ago

https://discourse.nixos.org/t/cant-get-gnupg-to-work-no-pinentry/15373

https://github.com/NixOS/nixpkgs/issues/35464

aleeusgr commented 1 week ago

here I forgot to -S my commits, fix by running git rebase --signoff HEAD~2 but getting the error

image

suggested fix:

git config --global gpg.ssh.allowedSignersFile
"~/.config/git/allowed_signers"
aleeusgr commented 1 week ago

Still the commits are listed as unverified: image

I signed with ssh key: image

But I need to sign with GPG: image

aleeusgr commented 1 week ago

Maybe the key here is wrong? https://github.com/aleeusgr/nix-things/blob/8700390f3556e547e8b39fbb1d3317c00ea9ba80/home.nix#L79-L93

aleeusgr commented 1 week ago

Try steps listed here:

https://docs.github.com/en/authentication/managing-commit-signature-verification/telling-git-about-your-signing-key

aleeusgr commented 1 week ago

Should I resign the commits or just wait for approval, then scratch this branch and open another PR?

https://stackoverflow.com/questions/62701112/is-there-a-way-to-remove-gpg-sign-of-all-previous-commits-or-resign-it-with-anot