diff options
author | aszlig <aszlig@redmoonstudios.org> | 2016-02-03 14:21:45 +0100 |
---|---|---|
committer | aszlig <aszlig@redmoonstudios.org> | 2016-02-03 15:48:52 +0100 |
commit | 80983bbe54cfb69f361e64b8b8cdb5ab79720ec7 (patch) | |
tree | 6cd447d32197ebdd2aab1cc292bb0f9fd2fe1e6c /nixos/modules | |
parent | ee68bdc42e2d1f3826d69ca2a2ecca3db108b7b5 (diff) | |
download | nixlib-80983bbe54cfb69f361e64b8b8cdb5ab79720ec7.tar nixlib-80983bbe54cfb69f361e64b8b8cdb5ab79720ec7.tar.gz nixlib-80983bbe54cfb69f361e64b8b8cdb5ab79720ec7.tar.bz2 nixlib-80983bbe54cfb69f361e64b8b8cdb5ab79720ec7.tar.lz nixlib-80983bbe54cfb69f361e64b8b8cdb5ab79720ec7.tar.xz nixlib-80983bbe54cfb69f361e64b8b8cdb5ab79720ec7.tar.zst nixlib-80983bbe54cfb69f361e64b8b8cdb5ab79720ec7.zip |
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 <aszlig@redmoonstudios.org>
Diffstat (limited to 'nixos/modules')
-rw-r--r-- | nixos/modules/services/hardware/udev.nix | 27 |
1 files changed, 23 insertions, 4 deletions
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 |