Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 60 lines 1.4 kB view raw
1{ 2 stdenv, 3 usbrelay, 4 python3, 5 installShellFiles, 6 udevCheckHook, 7}: 8let 9 python = python3.withPackages ( 10 ps: with ps; [ 11 usbrelay-py 12 paho-mqtt 13 ] 14 ); 15in 16# This is a separate derivation, not just an additional output of 17# usbrelay, because otherwise, we have a cyclic dependency between 18# usbrelay (default.nix) and the python module (python.nix). 19stdenv.mkDerivation { 20 pname = "usbrelayd"; 21 22 inherit (usbrelay) src version; 23 24 postPatch = '' 25 substituteInPlace 'usbrelayd.service' \ 26 --replace '/usr/bin/python3' "${python}/bin/python3" \ 27 --replace '/usr/sbin/usbrelayd' "$out/bin/usbrelayd" 28 ''; 29 30 nativeBuildInputs = [ 31 installShellFiles 32 udevCheckHook 33 ]; 34 35 buildInputs = [ python ]; 36 37 dontBuild = true; 38 39 doInstallCheck = true; 40 41 installPhase = '' 42 runHook preInstall; 43 install -m 644 -D usbrelayd $out/bin/usbrelayd 44 install -m 644 -D usbrelayd.service $out/lib/systemd/system/usbrelayd.service 45 install -m 644 -D 50-usbrelay.rules $out/lib/udev/rules.d/50-usbrelay.rules 46 install -m 644 -D usbrelayd.conf $out/etc/usbrelayd.conf # include this as an example 47 installManPage usbrelayd.8 48 runHook postInstall 49 ''; 50 51 meta = { 52 description = "USB Relay MQTT service"; 53 inherit (usbrelay.meta) 54 homepage 55 license 56 maintainers 57 platforms 58 ; 59 }; 60}