summary refs log tree commit diff
path: root/pkgs/development/tools/misc/usb-modeswitch/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/tools/misc/usb-modeswitch/default.nix')
-rw-r--r--pkgs/development/tools/misc/usb-modeswitch/default.nix30
1 files changed, 22 insertions, 8 deletions
diff --git a/pkgs/development/tools/misc/usb-modeswitch/default.nix b/pkgs/development/tools/misc/usb-modeswitch/default.nix
index a0e1b8eb8ce..731ac836412 100644
--- a/pkgs/development/tools/misc/usb-modeswitch/default.nix
+++ b/pkgs/development/tools/misc/usb-modeswitch/default.nix
@@ -1,4 +1,5 @@
-{ stdenv, fetchurl, pkgconfig, libusb1 }:
+{ stdenv, lib, fetchurl, pkgconfig, makeWrapper
+, libusb1, tcl, utillinux, coreutils, bash }:
 
 stdenv.mkDerivation rec {
   pname = "usb-modeswitch";
@@ -9,19 +10,32 @@ stdenv.mkDerivation rec {
     sha256 = "18wbbxc5cfsmikba0msdvd5qlaga27b32nhrzicyd9mdddp265f2";
   };
 
+  patches = [ ./configurable-usb-modeswitch.patch ];
+
+  # Remove attempts to write to /etc and /var/lib.
+  postPatch = ''
+    sed -i \
+      -e '/^\tinstall .* usb_modeswitch.conf/s,$(ETCDIR),$(out)/etc,' \
+      -e '\,^\tinstall -d .*/var/lib/usb_modeswitch,d' \
+      Makefile
+  '';
+
   makeFlags = [
-    "DESTDIR=$(out)"
     "PREFIX=$(out)"
+    "ETCDIR=/etc"
+    "USE_UPSTART=false"
+    "USE_SYSTEMD=true"
+    "SYSDIR=$(out)/lib/systemd/system"
+    "UDEVDIR=$(out)/lib/udev"
   ];
 
-  # make clean: we always build from source. It should be necessary on x86_64 only
-  preConfigure = ''
-    find -type f | xargs sed 's@/bin/rm@rm@g' -i
-    make clean
+  postFixup = ''
+    wrapProgram $out/bin/usb_modeswitch_dispatcher \
+      --set PATH ${lib.makeBinPath [ utillinux coreutils bash ]}
   '';
 
-  buildInputs = [ libusb1 ];
-  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ libusb1 tcl ];
+  nativeBuildInputs = [ pkgconfig makeWrapper ];
 
   meta = with stdenv.lib; {
     description = "A mode switching tool for controlling 'multi-mode' USB devices";