From 80983bbe54cfb69f361e64b8b8cdb5ab79720ec7 Mon Sep 17 00:00:00 2001 From: aszlig Date: Wed, 3 Feb 2016 14:21:45 +0100 Subject: nixos/udev: Provide a better warning for FHS paths We were trying to find FHS references in all of the rules found in services.udev.packages. Unfortunately we're still fixing up paths in the same derivation where we are checking those references, so for example references to /sbin/modprobe were still printed to be needed to fixup even though they were already fixed at the time. So now we're printing a more helpful warning message which is also conditional (before the warning message was printed regardless of whether there are any rules that need fixup) and is based off the rules that were already fixed up. The new warning message not only contains the build-local rule files but also the original files from other store paths and the FHS path references that were still found. With 8ecd3a5e1db40d308d60b5ccfa40eabccb419be9 reverted, we now get this: /nix/store/...-udev-rules/63-md-raid-arrays.rules (originally from /nix/store/...-mdadm-3.3.4/lib/udev/rules.d/63-md-raid-arrays.rules) contains references to /usr/bin/readlink and /usr/bin/basename. Which is now more accurate to what is not yet fixed and where it's coming from. Signed-off-by: aszlig --- nixos/modules/services/hardware/udev.nix | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'nixos') diff --git a/nixos/modules/services/hardware/udev.nix b/nixos/modules/services/hardware/udev.nix index 1821fe8c0b8a..dc87c9215e65 100644 --- a/nixos/modules/services/hardware/udev.nix +++ b/nixos/modules/services/hardware/udev.nix @@ -94,10 +94,29 @@ let done echo "OK" - echo "Consider fixing the following udev rules:" - for i in ${toString cfg.packages}; do - grep -l '\(RUN+\|IMPORT{program}\)="\(/usr\)\?/s\?bin' $i/*/udev/rules.d/* || true - done + filesToFixup="$(for i in "$out"/*; do + grep -l '\B\(/usr\)\?/s\?bin' "$i" || : + done)" + + if [ -n "$filesToFixup" ]; then + echo "Consider fixing the following udev rules:" + echo "$filesToFixup" | while read localFile; do + remoteFile="origin unknown" + for i in ${toString cfg.packages}; do + for j in "$i"/*/udev/rules.d/*; do + if [ -e "$out/$(basename "$j")" ]; then + remoteFile="originally from $j" + break 2 + fi + done + done + refs="$( + grep -o '\B\(/usr\)\?/s\?bin/[^ "]\+' "$localFile" \ + | sed -e ':r;N;''${s/\n/ and /;br};s/\n/, /g;br' + )" + echo "$localFile ($remoteFile) contains references to $refs." + done + fi ${optionalString config.networking.usePredictableInterfaceNames '' cp ${./80-net-setup-link.rules} $out/80-net-setup-link.rules -- cgit 1.4.1