@@ -1,4 +1,14 @@
1−{ stdenv, fetchurl, pkgconfig, systemd ? null, libobjc, IOKit, withStatic ? false }:
1+{ stdenv
2+, fetchurl
3+, pkgconfig
4+, enableSystemd ? stdenv.isLinux && !stdenv.hostPlatform.isMusl
5+, systemd ? null
6+, libobjc
7+, IOKit
8+, withStatic ? false
9+}:
10+
11+assert enableSystemd -> systemd != null;
212
313stdenv.mkDerivation (rec {
414 pname = "libusb";
@@ -13,12 +23,17 @@ stdenv.mkDerivation (rec {
1323
1424 nativeBuildInputs = [ pkgconfig ];
1525 propagatedBuildInputs =
16− stdenv.lib.optional stdenv.isLinux systemd ++
26+ stdenv.lib.optional enableSystemd systemd ++
1727 stdenv.lib.optionals stdenv.isDarwin [ libobjc IOKit ];
1828
1929 NIX_LDFLAGS = stdenv.lib.optionalString stdenv.isLinux "-lgcc_s";
2030
21− preFixup = stdenv.lib.optionalString stdenv.isLinux ''
31+ configureFlags =
32+ # We use `isLinux` here only to avoid mass rebuilds for Darwin, where
33+ # disabling udev happens automatically. Remove `isLinux` at next big change!
34+ stdenv.lib.optional (stdenv.isLinux && !enableSystemd) "--disable-udev";
35+
36+ preFixup = stdenv.lib.optionalString enableSystemd ''
2237 sed 's,-ludev,-L${systemd.lib}/lib -ludev,' -i $out/lib/libusb-1.0.la
2338 '';
2439