1{ lib, stdenv, fetchFromGitHub, autoreconfHook, autogen, pkg-config, python3
2, flac, lame, libmpg123, libogg, libopus, libvorbis
3, alsa-lib, Carbon, AudioToolbox
4}:
5
6stdenv.mkDerivation rec {
7 pname = "libsndfile";
8 version = "1.2.0";
9
10 src = fetchFromGitHub {
11 owner = pname;
12 repo = pname;
13 rev = version;
14 hash = "sha256-zd0HDUzVYLyFjhIudBJQaKJUtYMjZeQRLALSkyD9tXU=";
15 };
16
17 nativeBuildInputs = [ autoreconfHook autogen pkg-config python3 ];
18 buildInputs = [ flac lame libmpg123 libogg libopus libvorbis ]
19 ++ lib.optionals stdenv.isLinux [ alsa-lib ]
20 ++ lib.optionals stdenv.isDarwin [ Carbon AudioToolbox ];
21
22 enableParallelBuilding = true;
23
24 outputs = [ "bin" "dev" "out" "man" "doc" ];
25
26 # need headers from the Carbon.framework in /System/Library/Frameworks to
27 # compile this on darwin -- not sure how to handle
28 preConfigure = lib.optionalString stdenv.isDarwin
29 ''
30 NIX_CFLAGS_COMPILE+=" -I$SDKROOT/System/Library/Frameworks/Carbon.framework/Versions/A/Headers"
31 '';
32
33 # Needed on Darwin.
34 NIX_CFLAGS_LINK = "-logg -lvorbis";
35
36 meta = with lib; {
37 description = "A C library for reading and writing files containing sampled sound";
38 homepage = "https://libsndfile.github.io/libsndfile/";
39 changelog = "https://github.com/libsndfile/libsndfile/releases/tag/${version}";
40 license = licenses.lgpl2Plus;
41 maintainers = with maintainers; [ lovek323 ];
42 platforms = platforms.unix;
43
44 longDescription = ''
45 Libsndfile is a C library for reading and writing files containing
46 sampled sound (such as MS Windows WAV and the Apple/SGI AIFF format)
47 through one standard library interface. It is released in source
48 code format under the GNU Lesser General Public License.
49
50 The library was written to compile and run on a Linux system but
51 should compile and run on just about any Unix (including macOS).
52 There are also pre-compiled binaries available for 32 and 64 bit
53 windows.
54
55 It was designed to handle both little-endian (such as WAV) and
56 big-endian (such as AIFF) data, and to compile and run correctly on
57 little-endian (such as Intel and DEC/Compaq Alpha) processor systems
58 as well as big-endian processor systems such as Motorola 68k, Power
59 PC, MIPS and SPARC. Hopefully the design of the library will also
60 make it easy to extend for reading and writing new sound file
61 formats.
62 '';
63 };
64}