1{ lib
2, stdenv
3, fetchFromGitHub
4, cmake
5, freedvSupport ? false
6, lpcnetfreedv
7, codec2
8}:
9
10stdenv.mkDerivation rec {
11 pname = "codec2";
12 version = "1.1.0";
13
14 src = fetchFromGitHub {
15 owner = "drowe67";
16 repo = "codec2";
17 rev = "v${version}";
18 hash = "sha256-7E/Iqan3DVFl9pwsY6pwWM64ug1cjN6DH+u7XzraA78=";
19 };
20
21 nativeBuildInputs = [ cmake ];
22
23 buildInputs = lib.optionals freedvSupport [
24 lpcnetfreedv
25 ];
26
27 # Install a binary that is used by openwebrx
28 postInstall = ''
29 install -Dm0755 src/freedv_rx -t $out/bin/
30 '';
31
32 # Swap keyword order to satisfy SWIG parser
33 postFixup = ''
34 sed -r -i 's/(\<_Complex)(\s+)(float|double)/\3\2\1/' $out/include/$pname/freedv_api.h
35 '';
36
37 cmakeFlags = [
38 # RPATH of binary /nix/store/.../bin/freedv_rx contains a forbidden reference to /build/
39 "-DCMAKE_SKIP_BUILD_RPATH=ON"
40 ] ++ lib.optionals freedvSupport [
41 "-DLPCNET=ON"
42 ];
43
44 meta = with lib; {
45 description = "Speech codec designed for communications quality speech at low data rates";
46 homepage = "https://www.rowetel.com/codec2.html";
47 license = licenses.lgpl21Only;
48 platforms = platforms.unix;
49 maintainers = with maintainers; [ markuskowa ];
50 };
51}