package.nix (2134B)
1 { 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 fetchpatch, 6 fftwFloat, 7 libsamplerate, 8 libsndfile, 9 libusb1, 10 portaudio, 11 rtl-sdr, 12 qt5, 13 libsForQt5, 14 }: 15 16 stdenv.mkDerivation (finalAttrs: { 17 pname = "fmreceiver"; 18 version = "2.1"; 19 20 src = fetchFromGitHub { 21 owner = "JvanKatwijk"; 22 repo = "sdr-j-fm"; 23 tag = finalAttrs.version; 24 hash = "sha256-U0m9PIB+X+TBoz5FfXMvR/tZjkNIy7B613I7eLT5UIs="; 25 }; 26 27 patches = [ 28 # support qwt-6.2.0 29 (fetchpatch { 30 url = "https://github.com/JvanKatwijk/sdr-j-fm/commit/4ca2f3a28e3e3460dc95be851fcd923e91488573.patch"; 31 hash = "sha256-tjNsg9Rc8kBn+6UzPsf1WLt+ZRYv8neG/CSyZKjObh0="; 32 }) 33 ]; 34 35 postPatch = 36 '' 37 substituteInPlace fmreceiver.pro \ 38 --replace-fail "-lqwt-qt5" "-lqwt" \ 39 --replace-fail "CONFIG" "#CONFIG" 40 '' 41 + lib.optionalString stdenv.isDarwin '' 42 substituteInPlace fmreceiver.pro --replace-fail "-lrt " "" 43 substituteInPlace includes/fm-constants.h --replace-fail "<malloc.h>" "<stdlib.h>" 44 substituteInPlace devices/rtlsdr-handler/rtlsdr-handler.cpp --replace-fail ".so" ".dylib" 45 ''; 46 47 nativeBuildInputs = [ 48 qt5.qmake 49 qt5.wrapQtAppsHook 50 ]; 51 52 buildInputs = [ 53 fftwFloat 54 libsamplerate 55 libsndfile 56 libusb1 57 portaudio 58 libsForQt5.qwt 59 ]; 60 61 qmakeFlags = [ "CONFIG+=dabstick" ]; 62 63 qtWrapperArgs = [ 64 "--prefix ${lib.optionalString stdenv.isDarwin "DY"}LD_LIBRARY_PATH : ${ 65 lib.makeLibraryPath [ rtl-sdr ] 66 }" 67 ]; 68 69 installPhase = 70 if stdenv.isDarwin then 71 '' 72 mkdir -p $out/Applications 73 mv linux-bin/fmreceiver-2.0.app $out/Applications/fmreceiver.app 74 install_name_tool -change {,${libsForQt5.qwt}/lib/}libqwt.6.dylib "$out/Applications/fmreceiver.app/Contents/MacOS/fmreceiver-2.0" 75 '' 76 else 77 '' 78 install -Dm755 linux-bin/fmreceiver-2.0 $out/bin/fmreceiver 79 ''; 80 81 meta = { 82 description = "A simple FM receiver"; 83 homepage = "https://github.com/JvanKatwijk/sdr-j-fm"; 84 license = lib.licenses.gpl2Plus; 85 maintainers = [ lib.maintainers.sikmir ]; 86 platforms = lib.platforms.unix; 87 }; 88 })