2019-10-14 13:11:43 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
{
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
yubikey-personalization
|
2020-01-11 20:00:01 +00:00
|
|
|
yubikey-manager
|
2023-01-25 22:27:16 +00:00
|
|
|
pinentry-curses pinentry-qt
|
2019-10-14 13:11:43 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
services.udev.packages = with pkgs; [ yubikey-personalization ];
|
2020-01-11 20:00:01 +00:00
|
|
|
systemd.user.sockets.gpg-agent-ssh.wantedBy = [ "sockets.target" ];
|
|
|
|
|
2022-01-15 11:22:15 +00:00
|
|
|
services.pcscd.enable = true;
|
|
|
|
systemd.user.services.gpg-agent.serviceConfig.ExecStartPre = pkgs.writers.writeDash "init_gpg" ''
|
|
|
|
set -x
|
2023-01-25 22:27:16 +00:00
|
|
|
mkdir -p $HOME/.gnupg
|
2022-01-15 11:22:15 +00:00
|
|
|
${pkgs.coreutils}/bin/ln -sf ${pkgs.writeText "scdaemon.conf" ''
|
|
|
|
disable-ccid
|
|
|
|
pcsc-driver ${pkgs.pcsclite.out}/lib/libpcsclite.so.1
|
|
|
|
card-timeout 1
|
|
|
|
|
|
|
|
# Always try to use yubikey as the first reader
|
|
|
|
# even when other smart card readers are connected
|
|
|
|
# Name of the reader can be found using the pcsc_scan command
|
|
|
|
# If you have problems with gpg not recognizing the Yubikey
|
|
|
|
# then make sure that the string here matches exacly pcsc_scan
|
|
|
|
# command output. Also check journalctl -f for errors.
|
|
|
|
reader-port Yubico YubiKey
|
|
|
|
''} $HOME/.gnupg/scdaemon.conf
|
|
|
|
'';
|
2023-01-25 22:27:16 +00:00
|
|
|
systemd.user.services.gpg-agent.serviceConfig.ExecStartPost = pkgs.writers.writeDash "init_gpg" ''
|
|
|
|
${pkgs.gnupg}/bin/gpg --import ${../../kartei/lass/pgp/yubikey.pgp} >/dev/null
|
|
|
|
echo -e '5\ny\n' | gpg --command-fd 0 --expert --edit-key DBCD757846069B392EA9401D6657BE8A8D1EE807 trust >/dev/null || :
|
|
|
|
'';
|
2022-01-15 11:22:15 +00:00
|
|
|
|
|
|
|
security.polkit.extraConfig = ''
|
|
|
|
polkit.addRule(function(action, subject) {
|
|
|
|
if (
|
|
|
|
(
|
|
|
|
action.id == "org.debian.pcsc-lite.access_pcsc" ||
|
|
|
|
action.id == "org.debian.pcsc-lite.access_card"
|
|
|
|
) && subject.user == "lass"
|
|
|
|
) {
|
|
|
|
return polkit.Result.YES;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
polkit.addRule(function(action, subject) {
|
2023-01-25 22:27:16 +00:00
|
|
|
polkit.log("subject: " + subject + " action: " + action);
|
2022-01-15 11:22:15 +00:00
|
|
|
});
|
|
|
|
'';
|
2019-10-14 13:11:43 +00:00
|
|
|
|
2022-01-15 11:22:35 +00:00
|
|
|
# allow nix to acces remote builders via yubikey
|
|
|
|
systemd.services.nix-daemon.environment.SSH_AUTH_SOCK = "/run/user/1337/gnupg/S.gpg-agent.ssh";
|
|
|
|
|
2019-10-14 13:11:43 +00:00
|
|
|
programs = {
|
|
|
|
ssh.startAgent = false;
|
|
|
|
gnupg.agent = {
|
|
|
|
enable = true;
|
2023-01-25 22:27:16 +00:00
|
|
|
pinentryFlavor = "qt";
|
2023-09-03 10:15:37 +00:00
|
|
|
enableSSHSupport = true;
|
2019-10-14 13:11:43 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|