2022-07-15 13:11:54 +02:00
|
|
|
{ config
|
|
|
|
, lib
|
|
|
|
, pkgs
|
|
|
|
, ...
|
|
|
|
}:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.my.yubikey;
|
|
|
|
in
|
|
|
|
{
|
2023-03-14 09:52:28 +01:00
|
|
|
options.my.yubikey = {
|
|
|
|
enable = mkEnableOption "yubikey";
|
|
|
|
luksSupport = {
|
|
|
|
enable = mkEnableOption "fido2 luks support";
|
|
|
|
devices = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [ ];
|
|
|
|
description = "List of luks devices to enable fido2 support for.";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-07-15 13:11:54 +02:00
|
|
|
|
2023-03-14 09:52:28 +01:00
|
|
|
config = mkIf cfg.enable {
|
2022-07-15 13:11:54 +02:00
|
|
|
services.udev.packages = [ pkgs.yubikey-personalization ];
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
# cli
|
|
|
|
yubikey-manager
|
|
|
|
yubikey-personalization
|
|
|
|
paperkey
|
|
|
|
# graphical
|
|
|
|
yubikey-manager-qt
|
|
|
|
yubikey-personalization-gui
|
|
|
|
];
|
2023-03-14 09:52:28 +01:00
|
|
|
|
|
|
|
boot = mkIf cfg.luksSupport.enable {
|
|
|
|
initrd.systemd.enable = true;
|
|
|
|
initrd.luks.devices = genAttrs cfg.luksSupport.devices (_: {
|
|
|
|
crypttabExtraOpts = [ "fido2-device=auto" ];
|
|
|
|
});
|
|
|
|
};
|
2022-07-15 13:11:54 +02:00
|
|
|
};
|
|
|
|
}
|