1 { lib, stdenv, substituteAll }:
3 # Provides a facility to hook into rfkill changes.
7 # Add this package to udev.packages, e.g.:
8 # udev.packages = [ pkgs.rfkill_udev ];
10 # Add a hook script in the managed etc directory, e.g.:
11 # etc."rfkill.hook" = {
14 # #!${pkgs.runtimeShell}
16 # if [ "$RFKILL_STATE" -eq "1" ]; then
17 # exec ${config.system.build.upstart}/sbin/initctl emit -n antenna-on
19 # exec ${config.system.build.upstart}/sbin/initctl emit -n antenna-off
24 # Note: this package does not need the binaries
25 # in the rfkill package.
30 inherit (stdenv) shell;
32 src = ./rfkill-hook.sh;
34 in stdenv.mkDerivation {
41 mkdir -p "$out/etc/udev/rules.d/";
42 cat > "$out/etc/udev/rules.d/90-rfkill.rules" << EOF
43 SUBSYSTEM=="rfkill", ATTR{type}=="wlan", RUN+="$out/bin/rfkill-hook.sh"
47 cp ${rfkillHook} "$out/bin/rfkill-hook.sh"
51 homepage = "http://wireless.kernel.org/en/users/Documentation/rfkill";
52 description = "Rules+hook for udev to catch rfkill state changes";
53 mainProgram = "rfkill-hook.sh";
54 platforms = platforms.linux;
55 license = licenses.mit;