sdrpp: enable on darwin

+76 -5
+13 -4
pkgs/applications/radio/sdrpp/default.nix
··· 1 1 { stdenv, lib, fetchFromGitHub, cmake, pkg-config 2 - , libX11, glfw, glew, fftwFloat, volk 2 + , libX11, glfw, glew, fftwFloat, volk, AppKit 3 3 # Sources 4 4 , airspy_source ? true, airspy 5 5 , airspyhf_source ? true, airspyhf ··· 13 13 , sdrplay_source ? false, sdrplay 14 14 , soapy_source ? true, soapysdr 15 15 , spyserver_source ? true 16 - , plutosdr_source ? true, libiio, libad9361 16 + , plutosdr_source ? stdenv.isLinux, libiio, libad9361 17 17 # Sinks 18 18 , audio_sink ? true, rtaudio 19 19 , portaudio_sink ? false, portaudio ··· 42 42 hash = "sha256-g9tpWvVRMXRhPfgvOeJhX6IMouF9+tLUr9wo5r35i/c="; 43 43 }; 44 44 45 + patches = [ ./runtime-prefix.patch ]; 46 + 45 47 postPatch = '' 46 48 substituteInPlace CMakeLists.txt \ 47 - --replace "/usr" $out 49 + --replace "/usr/share" "share" \ 50 + --replace "set(CMAKE_INSTALL_PREFIX" "#set(CMAKE_INSTALL_PREFIX" 48 51 substituteInPlace decoder_modules/m17_decoder/src/m17dsp.h \ 49 52 --replace "codec2.h" "codec2/codec2.h" 50 53 ''; ··· 52 55 nativeBuildInputs = [ cmake pkg-config ]; 53 56 54 57 buildInputs = [ glfw glew fftwFloat volk ] 58 + ++ lib.optional stdenv.isDarwin AppKit 55 59 ++ lib.optional stdenv.isLinux libX11 56 60 ++ lib.optional airspy_source airspy 57 61 ++ lib.optional airspyhf_source airspyhf ··· 95 99 OPT_BUILD_RIGCTL_SERVER = rigctl_server; 96 100 }; 97 101 102 + CXXFLAGS = lib.optional stdenv.cc.isClang "-std=c++17"; 103 + LDFLAGS = lib.optional stdenv.cc.isClang "-lc++fs"; 104 + 98 105 NIX_CFLAGS_COMPILE = "-fpermissive"; 99 106 107 + hardeningDisable = lib.optional stdenv.cc.isClang "format"; 108 + 100 109 meta = with lib; { 101 110 description = "Cross-Platform SDR Software"; 102 111 homepage = "https://github.com/AlexandreRouma/SDRPlusPlus"; 103 112 license = licenses.gpl3Only; 104 - platforms = platforms.linux; 113 + platforms = platforms.unix; 105 114 maintainers = with maintainers; [ sikmir ]; 106 115 }; 107 116 }
+60
pkgs/applications/radio/sdrpp/runtime-prefix.patch
··· 1 + From a80a739163d2013ec400223a68a387f4f9297b2a Mon Sep 17 00:00:00 2001 2 + From: Nikolay Korotkiy <sikmir@gmail.com> 3 + Date: Fri, 29 Oct 2021 01:38:21 +0300 4 + Subject: [PATCH] Fix sdrpp breaking every time the package is rebuilt. 5 + 6 + On NixOS, the INSTALL_PREFIX changes on every rebuild to the package, but sdrpp 7 + fills it in as part of the default config and then installs that config 8 + to the users home folder. Fix this by not substituting @INSTALL_PREFIX@ in the 9 + default config until runtime. 10 + --- 11 + core/src/core.cpp | 8 ++++++-- 12 + core/src/gui/main_window.cpp | 6 ++++++ 13 + 2 files changed, 12 insertions(+), 2 deletions(-) 14 + 15 + diff --git a/core/src/core.cpp b/core/src/core.cpp 16 + index 9546e60..98d6065 100644 17 + --- a/core/src/core.cpp 18 + +++ b/core/src/core.cpp 19 + @@ -242,8 +242,8 @@ int sdrpp_main(int argc, char *argv[]) { 20 + defConfig["modulesDirectory"] = "./modules"; 21 + defConfig["resourcesDirectory"] = "./res"; 22 + #else 23 + - defConfig["modulesDirectory"] = INSTALL_PREFIX "/lib/sdrpp/plugins"; 24 + - defConfig["resourcesDirectory"] = INSTALL_PREFIX "/share/sdrpp"; 25 + + defConfig["modulesDirectory"] = "@prefix@/lib/sdrpp/plugins"; 26 + + defConfig["resourcesDirectory"] = "@prefix@/share/sdrpp"; 27 + #endif 28 + 29 + // Load config 30 + @@ -290,6 +290,10 @@ int sdrpp_main(int argc, char *argv[]) { 31 + int winHeight = core::configManager.conf["windowSize"]["h"]; 32 + maximized = core::configManager.conf["maximized"]; 33 + std::string resDir = core::configManager.conf["resourcesDirectory"]; 34 + + { 35 + + std::size_t pos = resDir.find("@prefix@"); 36 + + if (pos != std::string::npos) resDir.replace(pos, 8, INSTALL_PREFIX); 37 + + } 38 + json bandColors = core::configManager.conf["bandColors"]; 39 + core::configManager.release(); 40 + 41 + diff --git a/core/src/gui/main_window.cpp b/core/src/gui/main_window.cpp 42 + index 954dbd6..52f0eed 100644 43 + --- a/core/src/gui/main_window.cpp 44 + +++ b/core/src/gui/main_window.cpp 45 + @@ -44,6 +44,12 @@ void MainWindow::init() { 46 + json menuElements = core::configManager.conf["menuElements"]; 47 + std::string modulesDir = core::configManager.conf["modulesDirectory"]; 48 + std::string resourcesDir = core::configManager.conf["resourcesDirectory"]; 49 + + { 50 + + std::size_t pos = modulesDir.find("@prefix@"); 51 + + if (pos != std::string::npos) modulesDir.replace(pos, 8, INSTALL_PREFIX); 52 + + pos = resourcesDir.find("@prefix@"); 53 + + if (pos != std::string::npos) resourcesDir.replace(pos, 8, INSTALL_PREFIX); 54 + + } 55 + core::configManager.release(); 56 + 57 + // Load menu elements 58 + -- 59 + 2.33.0 60 +
+3 -1
pkgs/top-level/all-packages.nix
··· 19315 19315 19316 19316 sdrplay = callPackage ../applications/radio/sdrplay {}; 19317 19317 19318 - sdrpp = callPackage ../applications/radio/sdrpp { }; 19318 + sdrpp = callPackage ../applications/radio/sdrpp { 19319 + inherit (darwin.apple_sdk.frameworks) AppKit; 19320 + }; 19319 19321 19320 19322 sblim-sfcc = callPackage ../development/libraries/sblim-sfcc {}; 19321 19323