at 18.03-beta 49 lines 1.3 kB view raw
1{ stdenv }: 2 3# Provides a facility to hook into rfkill changes. 4# 5# Exemplary usage: 6# 7# Add this package to udev.packages, e.g.: 8# udev.packages = [ pkgs.rfkill_udev ]; 9# 10# Add a hook script in the managed etc directory, e.g.: 11# etc = [ 12# { source = pkgs.writeScript "rtfkill.hook" '' 13# #!/bin/sh 14# 15# if [ "$RFKILL_STATE" -eq "1" ]; then 16# exec ${config.system.build.upstart}/sbin/initctl emit -n antenna-on 17# else 18# exec ${config.system.build.upstart}/sbin/initctl emit -n antenna-off 19# fi 20# ''; 21# target = "rfkill.hook"; 22# } 23 24# Note: this package does not need the binaries 25# in the rfkill package. 26 27stdenv.mkDerivation { 28 name = "rfkill-udev"; 29 30 unpackPhase = "true"; 31 dontBuild = true; 32 33 installPhase = '' 34 mkdir -p "$out/etc/udev/rules.d/"; 35 cat > "$out/etc/udev/rules.d/90-rfkill.rules" << EOF 36 SUBSYSTEM=="rfkill", ATTR{type}=="wlan", RUN+="$out/bin/rfkill-hook.sh" 37 EOF 38 39 mkdir -p "$out/bin/"; 40 cp ${./rfkill-hook.sh} "$out/bin/rfkill-hook.sh" 41 chmod +x "$out/bin/rfkill-hook.sh"; 42 ''; 43 44 meta = { 45 homepage = http://wireless.kernel.org/en/users/Documentation/rfkill; 46 description = "Rules+hook for udev to catch rfkill state changes"; 47 platforms = stdenv.lib.platforms.linux; 48 }; 49}