nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 makeSetupHook,
4 systemdMinimal,
5 stdenv,
6}:
7let
8 # udev rules can only be checked if systemd (specifically, 'udevadm') can be executed on build platform
9 # If cross-compiling linux -> non-linux, udev rules are still checked, even if they end up being unused.
10 # This is not a problem:
11 # - If there are no udev rules, the hook is a noop
12 # - If the udev rules are broken, they should be flagged as such
13 # - if rules are not needed on a target platform where they are broken, they should be deleted from package output
14 applyHook = lib.meta.availableOn stdenv.buildPlatform systemdMinimal;
15in
16makeSetupHook {
17 name = "udev-check-hook";
18 substitutions = {
19 udevadm = if applyHook then lib.getExe' systemdMinimal "udevadm" else "";
20 };
21 meta = {
22 description = "Check validity of udev rules in outputs";
23 maintainers = with lib.maintainers; [ grimmauld ];
24 };
25} ./hook.sh