Grimmauld 1461a8401c
udevCheckHook: guard platform
It is technically possible to guard all udevCheckHook usages behind
`lib.optionals (lib.meta.availableOn stdenv.buildPlatform systemdMinimal)`.

However, doing this is hard to read, clunky, and hard to discover.
*Not* doing such a guard would mean cross-compilation darwin -> linux breaks.
The workaround here is to just accept any udev rules if they can't be properly checked.
2025-05-21 15:07:00 +02:00

28 lines
887 B
Bash

# shellcheck shell=bash
udevCheckHook() {
runHook preUdevCheck
echo Executing udevCheckPhase
# as per nixos/modules/services/hardware/udev.nix:
# - both /lib and /etc is valid paths for udev rules
# - udev rules are expected to be part of the $bin output
# However, not all udev rules are actually in $bin (some are in $lib or $out).
# This means we have to actually check all outputs here.
for output in $(getAllOutputNames); do
for path in etc lib ; do
if [ -d "${!output}/$path/udev/rules.d" ]; then
@udevadm@ verify --resolve-names=never --no-style "${!output}/$path/udev/rules.d"
fi
done
done
runHook postUdevCheck
echo Finished udevCheckPhase
}
if [[ -z "${dontUdevCheck-}" && -n "@udevadm@" ]]; then
echo "Using udevCheckHook"
preInstallCheckHooks+=(udevCheckHook)
fi