Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ stdenv, lib, fetchurl, pkg-config, makeWrapper
2, libusb1, tcl, util-linux, coreutils, bash }:
3
4stdenv.mkDerivation rec {
5 pname = "usb-modeswitch";
6 version = "2.6.0";
7
8 src = fetchurl {
9 url = "http://www.draisberghof.de/usb_modeswitch/${pname}-${version}.tar.bz2";
10 sha256 = "18wbbxc5cfsmikba0msdvd5qlaga27b32nhrzicyd9mdddp265f2";
11 };
12
13 patches = [ ./configurable-usb-modeswitch.patch ];
14
15 # Remove attempts to write to /etc and /var/lib.
16 postPatch = ''
17 sed -i \
18 -e '/^\tinstall .* usb_modeswitch.conf/s,$(ETCDIR),$(out)/etc,' \
19 -e '\,^\tinstall -d .*/var/lib/usb_modeswitch,d' \
20 Makefile
21 '';
22
23 makeFlags = [
24 "PREFIX=$(out)"
25 "ETCDIR=/etc"
26 "USE_UPSTART=false"
27 "USE_SYSTEMD=true"
28 "SYSDIR=$(out)/lib/systemd/system"
29 "UDEVDIR=$(out)/lib/udev"
30 ];
31
32 postFixup = ''
33 wrapProgram $out/bin/usb_modeswitch_dispatcher \
34 --set PATH ${lib.makeBinPath [ util-linux coreutils bash ]}
35 '';
36
37 buildInputs = [ libusb1 tcl ];
38 nativeBuildInputs = [ pkg-config makeWrapper ];
39
40 meta = with lib; {
41 description = "A mode switching tool for controlling 'multi-mode' USB devices";
42 license = licenses.gpl2;
43 maintainers = with maintainers; [ marcweber peterhoeg ];
44 platforms = platforms.linux;
45 };
46}