2021-01-11 08:54:33 +01:00
|
|
|
{ lib, stdenv, substituteAll }:
|
2012-02-24 02:35:59 +01: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 08:09:56 +01:00
|
|
|
# etc."rfkill.hook" = {
|
|
|
|
# mode = "0755";
|
|
|
|
# text = ''
|
|
|
|
# #!${pkgs.runtimeShell}
|
2012-02-24 02:35:59 +01:00
|
|
|
#
|
2020-01-11 08:09:56 +01: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 02:35:59 +01:00
|
|
|
|
|
|
|
# Note: this package does not need the binaries
|
|
|
|
# in the rfkill package.
|
|
|
|
|
2019-01-15 23:41:31 +01:00
|
|
|
let
|
|
|
|
rfkillHook =
|
|
|
|
substituteAll {
|
2019-03-06 00:10:34 +01:00
|
|
|
inherit (stdenv) shell;
|
|
|
|
isExecutable = true;
|
|
|
|
src = ./rfkill-hook.sh;
|
|
|
|
};
|
2019-01-15 23:41:31 +01:00
|
|
|
in stdenv.mkDerivation {
|
2012-02-24 02:35:59 +01:00
|
|
|
name = "rfkill-udev";
|
|
|
|
|
2019-06-19 17:45:34 +02:00
|
|
|
dontUnpack = true;
|
2012-02-24 02:35:59 +01:00
|
|
|
dontBuild = true;
|
|
|
|
|
|
|
|
installPhase = ''
|
2014-06-30 14:56:10 +02:00
|
|
|
mkdir -p "$out/etc/udev/rules.d/";
|
2012-02-24 02:35:59 +01:00
|
|
|
cat > "$out/etc/udev/rules.d/90-rfkill.rules" << EOF
|
2019-02-26 12:45:54 +01:00
|
|
|
SUBSYSTEM=="rfkill", ATTR{type}=="wlan", RUN+="$out/bin/rfkill-hook.sh"
|
2012-02-24 02:35:59 +01:00
|
|
|
EOF
|
|
|
|
|
2014-06-30 14:56:10 +02:00
|
|
|
mkdir -p "$out/bin/";
|
2019-01-15 23:41:31 +01:00
|
|
|
cp ${rfkillHook} "$out/bin/rfkill-hook.sh"
|
2012-02-24 02:35:59 +01:00
|
|
|
'';
|
|
|
|
|
2021-01-11 08:54:33 +01:00
|
|
|
meta = with lib; {
|
2020-04-01 03:11:51 +02:00
|
|
|
homepage = "http://wireless.kernel.org/en/users/Documentation/rfkill";
|
2012-02-24 02:35:59 +01:00
|
|
|
description = "Rules+hook for udev to catch rfkill state changes";
|
2020-06-30 21:27:03 +02:00
|
|
|
platforms = platforms.linux;
|
|
|
|
license = licenses.mit;
|
2012-02-24 02:35:59 +01:00
|
|
|
};
|
2019-01-15 23:41:31 +01:00
|
|
|
}
|