1{ stdenv, lib, fetchFromGitHub, fetchpatch, pkgconfig, cmake, git, doxygen, help2man, ncurses, tecla
2, libusb1, udev }:
3
4let
5 # fetch submodule
6 noos = fetchFromGitHub {
7 owner = "analogdevicesinc";
8 repo = "no-OS";
9 rev = "0bba46e6f6f75785a65d425ece37d0a04daf6157";
10 sha256 = "0is79dhsyp9xmlnfdr1i5s1c22ipjafk9d35jpn5dynpvj86m99c";
11 };
12
13 version = "2.2.0";
14
15in stdenv.mkDerivation {
16 name = "libbladeRF-${version}";
17
18 src = fetchFromGitHub {
19 owner = "Nuand";
20 repo = "bladeRF";
21 rev = "libbladeRF_v${version}";
22 sha256 = "0mdj5dkqg69gp0xw6gkhp86nxnm9g7az5rplnncxkp4p1kr35rnl";
23 };
24
25 nativeBuildInputs = [ pkgconfig ];
26 # ncurses used due to https://github.com/Nuand/bladeRF/blob/ab4fc672c8bab4f8be34e8917d3f241b1d52d0b8/host/utilities/bladeRF-cli/CMakeLists.txt#L208
27 buildInputs = [ cmake git doxygen help2man tecla libusb1 ]
28 ++ lib.optionals stdenv.isLinux [ udev ]
29 ++ lib.optionals stdenv.isDarwin [ ncurses ];
30
31
32 postUnpack = ''
33 cp -r ${noos}/* source/thirdparty/analogdevicesinc/no-OS/
34 '';
35
36 # Fixup shebang
37 prePatch = "patchShebangs host/utilities/bladeRF-cli/src/cmd/doc/generate.bash";
38
39 # Let us avoid nettools as a dependency.
40 postPatch = ''
41 sed -i 's/$(hostname)/hostname/' host/utilities/bladeRF-cli/src/cmd/doc/generate.bash
42 '';
43
44 cmakeFlags = [
45 "-DBUILD_DOCUMENTATION=ON"
46 ] ++ lib.optionals stdenv.isLinux [
47 "-DUDEV_RULES_PATH=etc/udev/rules.d"
48 "-DINSTALL_UDEV_RULES=ON"
49 "-DBLADERF_GROUP=bladerf"
50 ];
51
52 hardeningDisable = [ "fortify" ];
53
54 meta = with lib; {
55 homepage = https://nuand.com/libbladeRF-doc;
56 description = "Supporting library of the BladeRF SDR opensource hardware";
57 license = licenses.lgpl21;
58 maintainers = with maintainers; [ funfunctor ];
59 platforms = platforms.unix;
60 };
61}