nixos/systemd-stage-1: Fix FIDO2 udev rules

Fixes #368856

Changed files
+34 -6
nixos
modules
system
boot
pkgs
os-specific
linux
systemd
+1
nixos/modules/module-list.nix
···
./system/boot/systemd.nix
./system/boot/systemd/coredump.nix
./system/boot/systemd/dm-verity.nix
+
./system/boot/systemd/fido2.nix
./system/boot/systemd/initrd-secrets.nix
./system/boot/systemd/initrd.nix
./system/boot/systemd/journald.nix
+32
nixos/modules/system/boot/systemd/fido2.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 = [
+
"${pkgs.systemd}/lib/udev/fido_id"
+
"${cfg.package}/lib/cryptsetup/libcryptsetup-token-systemd-fido2.so"
+
"${pkgs.libfido2}/lib/libfido2.so.1"
+
];
+
};
+
}
-5
nixos/modules/system/boot/systemd/initrd.nix
···
# Resolving sysroot symlinks without code exec
"${pkgs.chroot-realpath}/bin/chroot-realpath"
]
-
++ optionals cfg.package.withCryptsetup [
-
# fido2 support
-
"${cfg.package}/lib/cryptsetup/libcryptsetup-token-systemd-fido2.so"
-
"${pkgs.libfido2}/lib/libfido2.so.1"
-
]
++ jobScripts
++ map (c: builtins.removeAttrs c [ "text" ]) (builtins.attrValues cfg.contents);
+1 -1
pkgs/os-specific/linux/systemd/default.nix
···
# needed - and therefore `interfaceVersion` should be incremented.
interfaceVersion = 2;
-
inherit withBootloader withCryptsetup withEfi withHostnamed withImportd withKmod
+
inherit withBootloader withCryptsetup withEfi withFido2 withHostnamed withImportd withKmod
withLocaled withMachined withPortabled withTimedated withTpm2Tss withUtmp
util-linux kmod kbd;