Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)

facetimehd: Only unload module if it is loaded

The pre-sleep service exits if any command fails. Unloading facetimehd
without it being loaded blocks subsequent commands from running.

Note: `modprobe -r` works a bit better when unloading unused modules,
and is preferrable to `rmmod`. However, the facetimehd module does not
support suspending. In this case, it seems preferable to forcefully
unload the module. `modprobe` does not support a `--force` flag when
removing, so we are left with `rmmod`.

See:
- https://github.com/NixOS/nixpkgs/pull/14883
- https://github.com/patjak/bcwc_pcie/wiki#known-issues

+1 -1
+1 -1
nixos/modules/hardware/video/webcam/facetimehd.nix
··· 31 31 32 32 # unload module during suspend/hibernate as it crashes the whole system 33 33 powerManagement.powerDownCommands = '' 34 - ${pkgs.kmod}/bin/rmmod -f facetimehd 34 + ${pkgs.kmod}/bin/lsmod | ${pkgs.gnugrep}/bin/grep -q "^facetimehd" && ${pkgs.kmod}/bin/rmmod -f -v facetimehd 35 35 ''; 36 36 37 37 # and load it back on resume