Skip to content

Commit

Permalink
libusb1: enable compiling with musl
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cdepillabout authored and nh2 committed Oct 26, 2019
1 parent b0e4d7b commit 08c0172
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions pkgs/development/libraries/libusb1/default.nix
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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
'';

Expand Down

0 comments on commit 08c0172

Please sign in to comment.