2022-09-17 00:19:18 +02:00
|
|
|
{ stdenv, usbrelay, python3, installShellFiles }:
|
2022-03-29 23:54:42 +02:00
|
|
|
let
|
|
|
|
python = python3.withPackages (ps: with ps; [ usbrelay-py paho-mqtt ]);
|
|
|
|
in
|
|
|
|
# This is a separate derivation, not just an additional output of
|
|
|
|
# usbrelay, because otherwise, we have a cyclic dependency between
|
|
|
|
# usbrelay (default.nix) and the python module (python.nix).
|
2023-06-02 08:21:37 +02:00
|
|
|
stdenv.mkDerivation {
|
2022-03-29 23:54:42 +02:00
|
|
|
pname = "usbrelayd";
|
|
|
|
|
|
|
|
inherit (usbrelay) src version;
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace 'usbrelayd.service' \
|
|
|
|
--replace '/usr/bin/python3' "${python}/bin/python3" \
|
|
|
|
--replace '/usr/sbin/usbrelayd' "$out/bin/usbrelayd"
|
|
|
|
'';
|
|
|
|
|
2022-09-17 00:19:18 +02:00
|
|
|
nativeBuildInputs = [ installShellFiles ];
|
|
|
|
|
2022-03-29 23:54:42 +02:00
|
|
|
buildInputs = [ python ];
|
|
|
|
|
|
|
|
dontBuild = true;
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall;
|
|
|
|
install -m 644 -D usbrelayd $out/bin/usbrelayd
|
|
|
|
install -m 644 -D usbrelayd.service $out/lib/systemd/system/usbrelayd.service
|
|
|
|
install -m 644 -D 50-usbrelay.rules $out/lib/udev/rules.d/50-usbrelay.rules
|
2022-05-08 21:16:32 +02:00
|
|
|
install -m 644 -D usbrelayd.conf $out/etc/usbrelayd.conf # include this as an example
|
2022-09-17 00:19:18 +02:00
|
|
|
installManPage usbrelayd.8
|
2022-03-29 23:54:42 +02:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "USB Relay MQTT service";
|
|
|
|
inherit (usbrelay.meta) homepage license maintainers platforms;
|
|
|
|
};
|
|
|
|
}
|