Files
nixpkgs/nixos/modules/system/boot/systemd/fido2.nix
r-vdp 503bfeb10f nixos/systemd/fido2: add libpcsclite_real.so.1 to initrd
libfido2 links against pcsclite's libpcsclite.so.1, which since
pcsclite 2.3.1 is a shim that dlopens libpcsclite_real.so.1. nixpkgs
patches that dlopen to an absolute store path. make-initrd-ng only
follows DT_NEEDED, so the real library never ends up in the initrd.

systemd-cryptsetup then logs at boot:

  loading ".../pcsclite-2.4.1-lib/lib/libpcsclite_real.so.1" failed:
  cannot open shared object file: No such file or directory

and FIDO2 tokens behind PC/SC (NFC readers) cannot be used to unlock
LUKS in stage 1. Add the real library to the initrd store paths.
2026-07-13 12:54:41 +02:00

35 lines
1017 B
Nix

{
lib,
config,
pkgs,
...
}:
let
cfg = config.boot.initrd.systemd;
in
{
options = {
boot.initrd.systemd.fido2.enable = lib.mkEnableOption "systemd FIDO2 support" // {
default = cfg.package.withFido2;
defaultText = lib.literalExpression "config.boot.initrd.systemd.package.withFido2";
};
};
config = lib.mkIf cfg.fido2.enable {
boot.initrd.services.udev.packages = [
# TODO: Add a better way to include upstream rules files.
(pkgs.runCommand "udev-fido2" { } ''
mkdir -p $out/lib/udev/rules.d/
cp ${cfg.package}/lib/udev/rules.d/60-fido-id.rules $out/lib/udev/rules.d/60-fido-id.rules
'')
];
boot.initrd.systemd.storePaths = [
"${cfg.package}/lib/udev/fido_id"
"${cfg.package}/lib/cryptsetup/libcryptsetup-token-systemd-fido2.so"
"${pkgs.libfido2}/lib/libfido2.so.1"
# dlopened by the libpcsclite.so.1 shim, invisible to make-initrd-ng
"${lib.getLib pkgs.pcsclite}/lib/libpcsclite_real.so.1"
];
};
}