Udev can't find script

this is a bit confounding

  extraRules = ''
    ACTION=="add", HID_NAME=="Framework HDMI Expansion Card", RUN+="/home/dot/.config/nixos/displayDetection.sh"
  '';
$ sudo nixos-rebuild switch --flake .
building the system configuration...
these 4 derivations will be built:
  /nix/store/6h9x9g20wsygkhi24lmkvr7bqsxb7896-udev-rules.drv
  /nix/store/fk2qpw030j581rn76ldxnqnczkxhrk8x-system-units.drv
  /nix/store/his9891g46jqpf50g600shpxihjy3zpk-etc.drv
  /nix/store/70977skqn995iw2icfxqds1b7hqpdnrq-nixos-system-nixos-24.05.20241012.a3f9ad6.drv
building '/nix/store/fk2qpw030j581rn76ldxnqnczkxhrk8x-system-units.drv'...
building '/nix/store/6h9x9g20wsygkhi24lmkvr7bqsxb7896-udev-rules.drv'...
error: builder for '/nix/store/6h9x9g20wsygkhi24lmkvr7bqsxb7896-udev-rules.drv' failed with exit code 1;
       last 10 log lines:
       > Copying /nix/store/37cp79f7ms6m84bzfssf92hc06xxcnga-steam-original-1.0.0.74/etc/udev/rules.d/60-steam-input.rules to /nix/store/vgiviw7xl5ycf0f4q04h8pvna0krs4sp-udev-rules/60-steam-input.rules
       > Copying /nix/store/37cp79f7ms6m84bzfssf92hc06xxcnga-steam-original-1.0.0.74/etc/udev/rules.d/60-steam-vr.rules to /nix/store/vgiviw7xl5ycf0f4q04h8pvna0krs4sp-udev-rules/60-steam-vr.rules
       > Adding rules for package /nix/store/77lq6240gpjd34p0vg725b710vddp0rp-iio-sensor-proxy-3.5
       > Copying /nix/store/77lq6240gpjd34p0vg725b710vddp0rp-iio-sensor-proxy-3.5/lib/udev/rules.d/80-iio-sensor-proxy.rules to /nix/store/vgiviw7xl5ycf0f4q04h8pvna0krs4sp-udev-rules/80-iio-sensor-proxy.rules
       > Adding rules for package /nix/store/ar3vcj9scyaw0lyravk39vl7gldavwcz-acpilight-1.2
       > Copying /nix/store/ar3vcj9scyaw0lyravk39vl7gldavwcz-acpilight-1.2/etc/udev/rules.d/90-backlight.rules to /nix/store/vgiviw7xl5ycf0f4q04h8pvna0krs4sp-udev-rules/90-backlight.rules
       > Checking that all programs called by relative paths in udev rules exist in /nix/store/nswmyag3qi9ars0mxw5lp8zm0wv5zxld-systemd-255.9/lib/udev... OK
       > Checking that all programs called by absolute paths in udev rules exist... grep: warning: stray \ before /
       > FAIL
       > /home/dot/.config/nixos/displayDetection.sh is called in udev rules but is not executable or does not exist
       For full logs, run 'nix log /nix/store/6h9x9g20wsygkhi24lmkvr7bqsxb7896-udev-rules.drv'.
error: 1 dependencies of derivation '/nix/store/his9891g46jqpf50g600shpxihjy3zpk-etc.drv' failed to build
error: 1 dependencies of derivation '/nix/store/70977skqn995iw2icfxqds1b7hqpdnrq-nixos-system-nixos-24.05.20241012.a3f9ad6.drv' failed to build
$ ll $PWD/displayDetection.sh
-rwxr-xr-x 1 dot users 242 Nov 28 07:58 /home/dot/.config/nixos/displayDetection.sh

any ideas? I’ve hardcoded the shell script to test it

These programs are checked at build time to make sure they’ll all actually exist, and impure paths like that aren’t visible in the build sandbox. It’s for the best too. NixOS systems should be buildable on a different system than they’ll be deployed to.

1 Like

Oh wow!!! That’s so awesome and totally makes sense.

Thank you SO MUCH for this direction!!