libusb1: enable compiling with musl

libusb1 can't depend on systemd in order to be compiling with musl,
because systemd can't be built with musl.

Since systemd provides udev, udev support needs to be disabled when
building libusb1.
This commit is contained in:
(cdep)illabout 2019-10-21 13:45:34 -04:00 committed by Niklas Hambüchen
parent b72984e7a3
commit 370d483a0d

View File

@ -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
'';