maintainers: remove email for amuckstot30 (#360059)
[NixPkgs.git] / pkgs / os-specific / linux / rfkill / udev.nix
blob53cbf68330c645c7424b0677814991f7efdabde9
1 { lib, stdenv, substituteAll }:
3 # Provides a facility to hook into rfkill changes.
5 # Exemplary usage:
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" = {
12 #     mode = "0755";
13 #     text = ''
14 #       #!${pkgs.runtimeShell}
16 #       if [ "$RFKILL_STATE" -eq "1" ]; then
17 #         exec ${config.system.build.upstart}/sbin/initctl emit -n antenna-on
18 #       else
19 #         exec ${config.system.build.upstart}/sbin/initctl emit -n antenna-off
20 #       fi
21 #     '';
22 #   }
24 # Note: this package does not need the binaries
25 # in the rfkill package.
27 let
28   rfkillHook =
29     substituteAll {
30       inherit (stdenv) shell;
31       isExecutable = true;
32       src = ./rfkill-hook.sh;
33     };
34 in stdenv.mkDerivation {
35   name = "rfkill-udev";
37   dontUnpack = true;
38   dontBuild = true;
40   installPhase = ''
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"
44     EOF
46     mkdir -p "$out/bin/";
47     cp ${rfkillHook} "$out/bin/rfkill-hook.sh"
48   '';
50   meta = with lib; {
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;
56   };