nix-community / home-manager

Manage a user environment using Nix [maintainer=@rycee]
https://nix-community.github.io/home-manager/
MIT License
7.17k stars 1.85k forks source link

bug: services.gpg-agent.enableSshSupport does not work on macOS #5997

Open shivangswain opened 1 month ago

shivangswain commented 1 month ago

Are you following the right branch?

Is there an existing issue for this?

Issue description

I believe SSH_AUTH_SOCK is only set by home-manager if it is empty, which is not the case in macOS by default. On my machine, it was set to:

> echo $SSH_AUTH_SOCK
/private/tmp/com.apple.launchd.ksw57i6cJR/Listeners

This causes:

> ssh-add -L
The agent has no identities.

To fix this, I had to add the following to my home.nix:

programs.zsh = {
  enable = true;
  initExtra = ''
    gpgconf --launch gpg-agent
  '';
  sessionVariables = {
    SSH_AUTH_SOCK = "$(gpgconf --list-dirs agent-ssh-socket)";
  };
};

Semi-linked to #3263 but created a new issue because I am not sure if it is an issue in Linux anymore. Also, that had gone stale.

Kudos to https://code.dumpstack.io/infra/localhost, specifically https://code.dumpstack.io/infra/localhost/commit/f44a829461b772654841e10203d79320c62635a6. Helped me fix this.

Maintainer CC

@rycee (maybe?)

System information

- system: `"aarch64-darwin"`
 - host os: `Darwin 24.0.0, macOS 15.0.1`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.24.9`
 - channels(root): `"nixpkgs"`
 - nixpkgs: `/nix/store/bc6afipyc33jj5iwp10acc848jj3fswr-source`
rycee commented 1 month ago

Sorry, don't think I can help much. I did merge https://github.com/nix-community/home-manager/pull/6001 a little while ago and perhaps that may help?

shivangswain commented 1 month ago

Thank you for your insight. I hope somebody else is able to figure this out.

folliehiyuki commented 1 month ago

I believe https://github.com/nix-community/home-manager/pull/5901 should fix your issue.