This commit is contained in:
Sam W 2024-09-28 20:10:46 +01:00
parent 665403ee0f
commit 700b56d41a
1 changed files with 6 additions and 6 deletions

View File

@ -2,11 +2,7 @@
{pkgs, config, lib, ...}: {
home.packages = [ pkgs.ssh-tpm-agent ];
home.sessionVariables = {
SSH_AUTH_SOCK = let
maybeProxy = lib.strings.optionalString config.services.gpg-agent.enableSshSupport "-A $(${config.programs.gpg.package}/bin/gpgconf --list-dirs agent-ssh-socket)";
cmd = "${pkgs.ssh-tpm-agent} --print-socket${maybeProxy}";
in "$(${cmd})";
TESTIFICLES = "hello";
SSH_AUTH_SOCK = "$(${pkgs.ssh-tpm-agent}/bin/ssh-tpm-agent --print-socket)";
};
systemd.user.sockets.ssh-tpm-agent = {
Unit.WantedBy = [ "sockets.target" ];
@ -26,7 +22,11 @@
Environment = ''
SSH_AUTH_SOCK="%t/ssh-tpm-agent.sock"
'';
ExecStart = "${pkgs.ssh-tpm-agent}";
ExecStart = "${pkgs.writeShellScriptBin "start-ssh-tpm-agent" (if config.services.gpg-agent.enableSshSupport then ''
${pkgs.ssh-tpm-agent}/bin/ssh-tpm-agent -A $(${config.programs.gpg.package}/bin/gpgconf --list-dirs agent-ssh-socket)
'' else ''
${pkgs.ssh-tpm-agent}/bin/ssh-tpm-agent
'')}/bin/start-ssh-tpm-agent";
PassEnvironment = "SSH_AGENT_PID";
SuccessExitStatus = 2;
Type = "simple";