lol
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 = [
14 ./configurable-usb-modeswitch.patch
15 ./pkg-config.patch
16 ];
17
18 # Remove attempts to write to /etc and /var/lib.
19 postPatch = ''
20 sed -i \
21 -e '/^\tinstall .* usb_modeswitch.conf/s,$(ETCDIR),$(out)/etc,' \
22 -e '\,^\tinstall -d .*/var/lib/usb_modeswitch,d' \
23 Makefile
24 '';
25
26 makeFlags = [
27 "PREFIX=$(out)"
28 "ETCDIR=/etc"
29 "USE_UPSTART=false"
30 "USE_SYSTEMD=true"
31 "SYSDIR=$(out)/lib/systemd/system"
32 "UDEVDIR=$(out)/lib/udev"
33 ];
34
35 postFixup = ''
36 wrapProgram $out/bin/usb_modeswitch_dispatcher \
37 --set PATH ${lib.makeBinPath [ util-linux coreutils bash ]}
38 '';
39
40 buildInputs = [ libusb1 tcl ];
41 nativeBuildInputs = [ pkg-config makeWrapper ];
42
43 meta = with lib; {
44 description = "A mode switching tool for controlling 'multi-mode' USB devices";
45 license = licenses.gpl2;
46 maintainers = with maintainers; [ marcweber peterhoeg ];
47 platforms = platforms.linux;
48 };
49}