e4029c34fc
This adds yubikey-agent as a package and a nixos module. On macOS, we use `wrapProgram` to set pinentry_mac as default in PATH; on Linux we rely on the user to set their preferred pinentry in PATH. In particular, we use a systemd override to prefix PATH to select a chosen pinentry program if specified. On Linux, we need libnotify to provide the notify-send utility for desktop notifications (such as "Waiting for Yubikey touch..."). This might work on other flavors of unix, but I haven't tested. We reuse the programs.gnupg.agent.pinentryFlavor option for yubikey-agent, but in doing so I hit a problem: pinentryFlavour's default value is specified in a mkDefault, but only conditionally. We ought to be able to pick up the pinentryFlavour whether or not gpg-agent is running. As a result, this commit moves the default value to the definition of programs.gnupg.agent.enable.
54 lines
1.9 KiB
Nix
54 lines
1.9 KiB
Nix
{ stdenv, lib, fetchFromGitHub, buildGoModule, libnotify, makeWrapper, pcsclite, pinentry_mac, pkgconfig, darwin }:
|
|
|
|
buildGoModule rec {
|
|
pname = "yubikey-agent";
|
|
version = "0.1.3";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "FiloSottile";
|
|
repo = pname;
|
|
rev = "v${version}";
|
|
sha256 = "07gix5wrakn4z846zhvl66lzwx58djrfnn6m8v7vc69l9jr3kihr";
|
|
};
|
|
|
|
buildInputs =
|
|
lib.optional stdenv.isLinux (lib.getDev pcsclite)
|
|
++ lib.optional stdenv.isDarwin (darwin.apple_sdk.frameworks.PCSC);
|
|
|
|
nativeBuildInputs = [ makeWrapper pkgconfig ];
|
|
|
|
# pull in go-piv/piv-go#75
|
|
# once go-piv/piv-go#75 is merged and released, we should
|
|
# use the released version (and push upstream to do the same)
|
|
patches = [ ./use-piv-go-75.patch ];
|
|
postPatch = lib.optionalString stdenv.isLinux ''
|
|
substituteInPlace main.go --replace 'notify-send' ${libnotify}/bin/notify-send
|
|
'';
|
|
|
|
vendorSha256 = "1x7934p6522i0yyv08xzb4134d0kr5x6igsrp26vh79d8fndbywr";
|
|
|
|
subPackages = [ "." ];
|
|
|
|
# On macOS, there isn't a choice of pinentry program, so let's
|
|
# ensure the nixpkgs-provided one is available
|
|
postInstall = lib.optionalString stdenv.isDarwin ''
|
|
wrapProgram $out/bin/yubikey-agent --suffix PATH : $(dirname ${pinentry_mac}/${pinentry_mac.binaryPath})
|
|
''
|
|
# Note: in the next release, upstream provides
|
|
# contrib/systemd/user/yubikey-agent.service, which we should use
|
|
# instead
|
|
# See https://github.com/FiloSottile/yubikey-agent/pull/43
|
|
+ lib.optionalString stdenv.isLinux ''
|
|
mkdir -p $out/lib/systemd/user
|
|
substitute ${./yubikey-agent.service} $out/lib/systemd/user/yubikey-agent.service \
|
|
--replace 'ExecStart=yubikey-agent' "ExecStart=$out/bin/yubikey-agent"
|
|
'';
|
|
|
|
meta = with lib; {
|
|
description = "A seamless ssh-agent for YubiKeys";
|
|
license = licenses.bsd3;
|
|
homepage = "https://filippo.io/yubikey-agent";
|
|
maintainers = with lib.maintainers; [ philandstuff rawkode ];
|
|
platforms = platforms.darwin ++ platforms.linux;
|
|
};
|
|
}
|