yubikey-agent: remove redundant platform checks
This commit is contained in:
@@ -19,79 +19,71 @@ in
|
|||||||
package = lib.mkPackageOption pkgs "yubikey-agent" { };
|
package = lib.mkPackageOption pkgs "yubikey-agent" { };
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable (
|
config = mkIf cfg.enable {
|
||||||
lib.mkMerge [
|
home.packages = [ cfg.package ];
|
||||||
{ home.packages = [ cfg.package ]; }
|
|
||||||
|
|
||||||
(mkIf pkgs.stdenv.isLinux {
|
home.sessionVariables.SSH_AUTH_SOCK =
|
||||||
systemd.user.services.yubikey-agent = {
|
if pkgs.stdenv.isDarwin then
|
||||||
Unit = {
|
"/tmp/yubikey-agent.sock"
|
||||||
Description = "Seamless ssh-agent for YubiKeys";
|
else
|
||||||
Documentation = "https://github.com/FiloSottile/yubikey-agent";
|
"\${XDG_RUNTIME_DIR:-/run/user/$UID}/yubikey-agent/yubikey-agent.sock";
|
||||||
Requires = "yubikey-agent.socket";
|
|
||||||
After = "yubikey-agent.socket";
|
|
||||||
RefuseManualStart = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
Service = {
|
systemd.user.services.yubikey-agent = {
|
||||||
ExecStart = "${cfg.package}/bin/yubikey-agent -l %t/yubikey-agent/yubikey-agent.sock";
|
Unit = {
|
||||||
Type = "simple";
|
Description = "Seamless ssh-agent for YubiKeys";
|
||||||
# /run/user/$UID for the socket
|
Documentation = "https://github.com/FiloSottile/yubikey-agent";
|
||||||
ReadWritePaths = [ "%t" ];
|
Requires = "yubikey-agent.socket";
|
||||||
|
After = "yubikey-agent.socket";
|
||||||
|
RefuseManualStart = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
Service = {
|
||||||
|
ExecStart = "${cfg.package}/bin/yubikey-agent -l %t/yubikey-agent/yubikey-agent.sock";
|
||||||
|
Type = "simple";
|
||||||
|
# /run/user/$UID for the socket
|
||||||
|
ReadWritePaths = [ "%t" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.user.sockets.yubikey-agent = {
|
||||||
|
Unit = {
|
||||||
|
Description = "Unix domain socket for Yubikey SSH agent";
|
||||||
|
Documentation = "https://github.com/FiloSottile/yubikey-agent";
|
||||||
|
};
|
||||||
|
|
||||||
|
Socket = {
|
||||||
|
ListenStream = "%t/yubikey-agent/yubikey-agent.sock";
|
||||||
|
RuntimeDirectory = "yubikey-agent";
|
||||||
|
SocketMode = "0600";
|
||||||
|
DirectoryMode = "0700";
|
||||||
|
};
|
||||||
|
|
||||||
|
Install = {
|
||||||
|
WantedBy = [ "sockets.target" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
launchd.agents.yubikey-agent = {
|
||||||
|
enable = true;
|
||||||
|
config = {
|
||||||
|
ProgramArguments = [
|
||||||
|
"${cfg.package}/bin/yubikey-agent"
|
||||||
|
"-l"
|
||||||
|
"/tmp/yubikey-agent.sock"
|
||||||
|
];
|
||||||
|
|
||||||
|
KeepAlive = {
|
||||||
|
Crashed = true;
|
||||||
|
SuccessfulExit = false;
|
||||||
|
};
|
||||||
|
ProcessType = "Background";
|
||||||
|
Sockets = {
|
||||||
|
Listener = {
|
||||||
|
SockPathName = "/tmp/yubikey-agent.sock";
|
||||||
|
SockPathMode = 384; # 0600 in decimal
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
systemd.user.sockets.yubikey-agent = {
|
};
|
||||||
Unit = {
|
};
|
||||||
Description = "Unix domain socket for Yubikey SSH agent";
|
|
||||||
Documentation = "https://github.com/FiloSottile/yubikey-agent";
|
|
||||||
};
|
|
||||||
|
|
||||||
Socket = {
|
|
||||||
ListenStream = "%t/yubikey-agent/yubikey-agent.sock";
|
|
||||||
RuntimeDirectory = "yubikey-agent";
|
|
||||||
SocketMode = "0600";
|
|
||||||
DirectoryMode = "0700";
|
|
||||||
};
|
|
||||||
|
|
||||||
Install = {
|
|
||||||
WantedBy = [ "sockets.target" ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
home.sessionVariables = {
|
|
||||||
SSH_AUTH_SOCK = "\${XDG_RUNTIME_DIR:-/run/user/$UID}/yubikey-agent/yubikey-agent.sock";
|
|
||||||
};
|
|
||||||
})
|
|
||||||
|
|
||||||
(mkIf pkgs.stdenv.isDarwin {
|
|
||||||
launchd.agents.yubikey-agent = {
|
|
||||||
enable = true;
|
|
||||||
config = {
|
|
||||||
ProgramArguments = [
|
|
||||||
"${cfg.package}/bin/yubikey-agent"
|
|
||||||
"-l"
|
|
||||||
"/tmp/yubikey-agent.sock"
|
|
||||||
];
|
|
||||||
|
|
||||||
KeepAlive = {
|
|
||||||
Crashed = true;
|
|
||||||
SuccessfulExit = false;
|
|
||||||
};
|
|
||||||
ProcessType = "Background";
|
|
||||||
Sockets = {
|
|
||||||
Listener = {
|
|
||||||
SockPathName = "/tmp/yubikey-agent.sock";
|
|
||||||
SockPathMode = 384; # 0600 in decimal
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
home.sessionVariables = {
|
|
||||||
SSH_AUTH_SOCK = "/tmp/yubikey-agent.sock";
|
|
||||||
};
|
|
||||||
})
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user