2019-01-15 22:41:31 +00:00
|
|
|
{ stdenv, substituteAll }:
|
2012-02-24 01:35:59 +00:00
|
|
|
|
|
|
|
# Provides a facility to hook into rfkill changes.
|
|
|
|
#
|
|
|
|
# Exemplary usage:
|
|
|
|
#
|
|
|
|
# Add this package to udev.packages, e.g.:
|
|
|
|
# udev.packages = [ pkgs.rfkill_udev ];
|
|
|
|
#
|
|
|
|
# Add a hook script in the managed etc directory, e.g.:
|
2020-01-11 07:09:56 +00:00
|
|
|
# etc."rfkill.hook" = {
|
|
|
|
# mode = "0755";
|
|
|
|
# text = ''
|
|
|
|
# #!${pkgs.runtimeShell}
|
2012-02-24 01:35:59 +00:00
|
|
|
#
|
2020-01-11 07:09:56 +00:00
|
|
|
# if [ "$RFKILL_STATE" -eq "1" ]; then
|
|
|
|
# exec ${config.system.build.upstart}/sbin/initctl emit -n antenna-on
|
|
|
|
# else
|
|
|
|
# exec ${config.system.build.upstart}/sbin/initctl emit -n antenna-off
|
|
|
|
# fi
|
|
|
|
# '';
|
|
|
|
# }
|
2012-02-24 01:35:59 +00:00
|
|
|
|
|
|
|
# Note: this package does not need the binaries
|
|
|
|
# in the rfkill package.
|
|
|
|
|
2019-01-15 22:41:31 +00:00
|
|
|
let
|
|
|
|
rfkillHook =
|
|
|
|
substituteAll {
|
2019-03-05 23:10:34 +00:00
|
|
|
inherit (stdenv) shell;
|
|
|
|
isExecutable = true;
|
|
|
|
src = ./rfkill-hook.sh;
|
|
|
|
};
|
2019-01-15 22:41:31 +00:00
|
|
|
in stdenv.mkDerivation {
|
2012-02-24 01:35:59 +00:00
|
|
|
name = "rfkill-udev";
|
|
|
|
|
2019-06-19 16:45:34 +01:00
|
|
|
dontUnpack = true;
|
2012-02-24 01:35:59 +00:00
|
|
|
dontBuild = true;
|
|
|
|
|
|
|
|
installPhase = ''
|
2014-06-30 13:56:10 +01:00
|
|
|
mkdir -p "$out/etc/udev/rules.d/";
|
2012-02-24 01:35:59 +00:00
|
|
|
cat > "$out/etc/udev/rules.d/90-rfkill.rules" << EOF
|
2019-02-26 11:45:54 +00:00
|
|
|
SUBSYSTEM=="rfkill", ATTR{type}=="wlan", RUN+="$out/bin/rfkill-hook.sh"
|
2012-02-24 01:35:59 +00:00
|
|
|
EOF
|
|
|
|
|
2014-06-30 13:56:10 +01:00
|
|
|
mkdir -p "$out/bin/";
|
2019-01-15 22:41:31 +00:00
|
|
|
cp ${rfkillHook} "$out/bin/rfkill-hook.sh"
|
2012-02-24 01:35:59 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = {
|
2020-04-01 02:11:51 +01:00
|
|
|
homepage = "http://wireless.kernel.org/en/users/Documentation/rfkill";
|
2012-02-24 01:35:59 +00:00
|
|
|
description = "Rules+hook for udev to catch rfkill state changes";
|
|
|
|
platforms = stdenv.lib.platforms.linux;
|
|
|
|
};
|
2019-01-15 22:41:31 +00:00
|
|
|
}
|