1 # Global configuration for yubikey-agent.
3 { config, lib, pkgs, ... }:
8 cfg = config.services.yubikey-agent;
13 meta.maintainers = with maintainers; [ philandstuff rawkode ];
17 services.yubikey-agent = {
22 Whether to start yubikey-agent when you log in. Also sets
23 SSH_AUTH_SOCK to point at yubikey-agent.
25 Note that yubikey-agent will use whatever pinentry is
26 specified in programs.gnupg.agent.pinentryPackage.
30 package = mkPackageOption pkgs "yubikey-agent" { };
34 config = mkIf cfg.enable {
35 environment.systemPackages = [ cfg.package ];
36 systemd.packages = [ cfg.package ];
38 # This overrides the systemd user unit shipped with the
39 # yubikey-agent package
40 systemd.user.services.yubikey-agent = mkIf (config.programs.gnupg.agent.pinentryPackage != null) {
41 path = [ config.programs.gnupg.agent.pinentryPackage ];
42 wantedBy = [ "default.target" ];
45 # Yubikey-agent expects pcsd to be running in order to function.
46 services.pcscd.enable = true;
48 environment.extraInit = ''
49 if [ -z "$SSH_AUTH_SOCK" -a -n "$XDG_RUNTIME_DIR" ]; then
50 export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/yubikey-agent/yubikey-agent.sock"