7 # Provides a facility to hook into rfkill changes.
11 # Add this package to udev.packages, e.g.:
12 # udev.packages = [ pkgs.rfkill_udev ];
14 # Add a hook script in the managed etc directory, e.g.:
15 # etc."rfkill.hook" = {
18 # #!${pkgs.runtimeShell}
20 # if [ "$RFKILL_STATE" -eq "1" ]; then
21 # exec ${config.system.build.upstart}/sbin/initctl emit -n antenna-on
23 # exec ${config.system.build.upstart}/sbin/initctl emit -n antenna-off
28 # Note: this package does not need the binaries
29 # in the rfkill package.
32 rfkillHook = replaceVarsWith {
33 replacements = { inherit (stdenv) shell; };
35 src = ./rfkill-hook.sh;
45 mkdir -p "$out/etc/udev/rules.d/";
46 cat > "$out/etc/udev/rules.d/90-rfkill.rules" << EOF
47 SUBSYSTEM=="rfkill", ATTR{type}=="wlan", RUN+="$out/bin/rfkill-hook.sh"
51 cp ${rfkillHook} "$out/bin/rfkill-hook.sh"
55 homepage = "http://wireless.kernel.org/en/users/Documentation/rfkill";
56 description = "Rules+hook for udev to catch rfkill state changes";
57 mainProgram = "rfkill-hook.sh";
58 platforms = platforms.linux;
59 license = licenses.mit;