···11+{
22+ config,
33+ lib,
44+ pkgs,
55+ ...
66+}:
77+let
88+ sock = "\${XDG_RUNTIME_DIR}/phonetpm/agent.sock";
99+in
1010+{
1111+ # Use the phonetpm daemon (configs/phonetpm.nix) as the ssh-agent: every
1212+ # signature asks for a fingerprint on the phone. Only a default: hosts that
1313+ # also import configs/tpm2.nix keep the TPM agent as SSH_AUTH_SOCK.
1414+ imports = [ ./phonetpm.nix ];
1515+1616+ environment.sessionVariables.SSH_AUTH_SOCK = lib.mkDefault sock;
1717+1818+ # systemd-launched programs don't source /etc/set-environment; publish the
1919+ # socket to the user manager like configs/tpm2.nix does, unless another
2020+ # agent owns SSH_AUTH_SOCK.
2121+ systemd.user.services.phonetpm.serviceConfig.ExecStartPost = lib.mkIf (
2222+ config.environment.sessionVariables.SSH_AUTH_SOCK == sock
2323+ ) "${pkgs.systemd}/bin/systemctl --user set-environment SSH_AUTH_SOCK=%t/phonetpm/agent.sock";
2424+2525+ # gnome-keyring pulls in gcr-ssh-agent, which also sets SSH_AUTH_SOCK in the
2626+ # user manager and would shadow phonetpm.
2727+ services.gnome.gcr-ssh-agent.enable = false;
2828+}
···99{
1010 # Phone-backed ssh-agent / age plugin (https://github.com/Lassulus/phonetpm).
1111 # The daemon serves %t/phonetpm/{agent,control}.sock; age-plugin-phone finds
1212- # the control socket on its own. SSH_AUTH_SOCK is intentionally left on the
1313- # TPM agent for now (configs/tpm2.nix).
1212+ # the control socket on its own. configs/phonetpm-ssh.nix makes it the
1313+ # SSH_AUTH_SOCK.
1414 environment.systemPackages = [ phonetpm ];
15151616 systemd.user.services.phonetpm = {