diff --git a/pkgs/development/libraries/libusb1/default.nix b/pkgs/development/libraries/libusb1/default.nix index 19a8025359a0..9a08a7756c84 100644 --- a/pkgs/development/libraries/libusb1/default.nix +++ b/pkgs/development/libraries/libusb1/default.nix @@ -1,4 +1,14 @@ -{ stdenv, fetchurl, pkgconfig, systemd ? null, libobjc, IOKit, withStatic ? false }: +{ stdenv +, fetchurl +, pkgconfig +, enableSystemd ? stdenv.isLinux && !stdenv.hostPlatform.isMusl +, systemd ? null +, libobjc +, IOKit +, withStatic ? false +}: + +assert enableSystemd -> systemd != null; stdenv.mkDerivation (rec { pname = "libusb"; @@ -13,12 +23,17 @@ stdenv.mkDerivation (rec { nativeBuildInputs = [ pkgconfig ]; propagatedBuildInputs = - stdenv.lib.optional stdenv.isLinux systemd ++ + stdenv.lib.optional enableSystemd systemd ++ stdenv.lib.optionals stdenv.isDarwin [ libobjc IOKit ]; NIX_LDFLAGS = stdenv.lib.optionalString stdenv.isLinux "-lgcc_s"; - preFixup = stdenv.lib.optionalString stdenv.isLinux '' + configureFlags = + # We use `isLinux` here only to avoid mass rebuilds for Darwin, where + # disabling udev happens automatically. Remove `isLinux` at next big change! + stdenv.lib.optional (stdenv.isLinux && !enableSystemd) "--disable-udev"; + + preFixup = stdenv.lib.optionalString enableSystemd '' sed 's,-ludev,-L${systemd.lib}/lib -ludev,' -i $out/lib/libusb-1.0.la '';