1{ lib, stdenv, fetchurl, pkg-config, libsndfile, ApplicationServices, Carbon, CoreServices }:
2
3let
4 inherit (lib) optionals optionalString;
5
6in stdenv.mkDerivation rec {
7 pname = "libsamplerate";
8 version = "0.2.2";
9
10 src = fetchurl {
11 url = "https://github.com/libsndfile/libsamplerate/releases/download/${version}/libsamplerate-${version}.tar.xz";
12 hash = "sha256-MljaKAUR0ktJ1rCGFbvoJNDKzJhCsOTK8RxSzysEOJM=";
13 };
14
15 nativeBuildInputs = [ pkg-config ];
16 buildInputs = [ libsndfile ]
17 ++ optionals stdenv.isDarwin [ ApplicationServices CoreServices ];
18
19 configureFlags = [ "--disable-fftw" ];
20
21 outputs = [ "dev" "out" ];
22
23 postConfigure = optionalString stdenv.isDarwin ''
24 # need headers from the Carbon.framework in /System/Library/Frameworks to
25 # compile this on darwin -- not sure how to handle
26 NIX_CFLAGS_COMPILE+=" -I${Carbon}/Library/Frameworks/Carbon.framework/Headers"
27 '';
28
29 meta = with lib; {
30 description = "Sample Rate Converter for audio";
31 homepage = "https://libsndfile.github.io/libsamplerate/";
32 license = licenses.bsd2;
33 maintainers = with maintainers; [ lovek323 ];
34 platforms = platforms.all;
35 };
36}