sdrpp: enable on darwin

This commit is contained in:
Nikolay Korotkiy 2021-10-28 15:34:46 +03:00
parent 19b87ec97d
commit 049264c39b
No known key found for this signature in database
GPG key ID: D1DE6D7F693663A5
3 changed files with 76 additions and 5 deletions

View file

@ -1,5 +1,5 @@
{ stdenv, lib, fetchFromGitHub, cmake, pkg-config
, libX11, glfw, glew, fftwFloat, volk
, libX11, glfw, glew, fftwFloat, volk, AppKit
# Sources
, airspy_source ? true, airspy
, airspyhf_source ? true, airspyhf
@ -13,7 +13,7 @@
, sdrplay_source ? false, sdrplay
, soapy_source ? true, soapysdr
, spyserver_source ? true
, plutosdr_source ? true, libiio, libad9361
, plutosdr_source ? stdenv.isLinux, libiio, libad9361
# Sinks
, audio_sink ? true, rtaudio
, portaudio_sink ? false, portaudio
@ -42,9 +42,12 @@ stdenv.mkDerivation rec {
hash = "sha256-g9tpWvVRMXRhPfgvOeJhX6IMouF9+tLUr9wo5r35i/c=";
};
patches = [ ./runtime-prefix.patch ];
postPatch = ''
substituteInPlace CMakeLists.txt \
--replace "/usr" $out
--replace "/usr/share" "share" \
--replace "set(CMAKE_INSTALL_PREFIX" "#set(CMAKE_INSTALL_PREFIX"
substituteInPlace decoder_modules/m17_decoder/src/m17dsp.h \
--replace "codec2.h" "codec2/codec2.h"
'';
@ -52,6 +55,7 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [ cmake pkg-config ];
buildInputs = [ glfw glew fftwFloat volk ]
++ lib.optional stdenv.isDarwin AppKit
++ lib.optional stdenv.isLinux libX11
++ lib.optional airspy_source airspy
++ lib.optional airspyhf_source airspyhf
@ -95,13 +99,18 @@ stdenv.mkDerivation rec {
OPT_BUILD_RIGCTL_SERVER = rigctl_server;
};
CXXFLAGS = lib.optional stdenv.cc.isClang "-std=c++17";
LDFLAGS = lib.optional stdenv.cc.isClang "-lc++fs";
NIX_CFLAGS_COMPILE = "-fpermissive";
hardeningDisable = lib.optional stdenv.cc.isClang "format";
meta = with lib; {
description = "Cross-Platform SDR Software";
homepage = "https://github.com/AlexandreRouma/SDRPlusPlus";
license = licenses.gpl3Only;
platforms = platforms.linux;
platforms = platforms.unix;
maintainers = with maintainers; [ sikmir ];
};
}

View file

@ -0,0 +1,60 @@
From a80a739163d2013ec400223a68a387f4f9297b2a Mon Sep 17 00:00:00 2001
From: Nikolay Korotkiy <sikmir@gmail.com>
Date: Fri, 29 Oct 2021 01:38:21 +0300
Subject: [PATCH] Fix sdrpp breaking every time the package is rebuilt.
On NixOS, the INSTALL_PREFIX changes on every rebuild to the package, but sdrpp
fills it in as part of the default config and then installs that config
to the users home folder. Fix this by not substituting @INSTALL_PREFIX@ in the
default config until runtime.
---
core/src/core.cpp | 8 ++++++--
core/src/gui/main_window.cpp | 6 ++++++
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/core/src/core.cpp b/core/src/core.cpp
index 9546e60..98d6065 100644
--- a/core/src/core.cpp
+++ b/core/src/core.cpp
@@ -242,8 +242,8 @@ int sdrpp_main(int argc, char *argv[]) {
defConfig["modulesDirectory"] = "./modules";
defConfig["resourcesDirectory"] = "./res";
#else
- defConfig["modulesDirectory"] = INSTALL_PREFIX "/lib/sdrpp/plugins";
- defConfig["resourcesDirectory"] = INSTALL_PREFIX "/share/sdrpp";
+ defConfig["modulesDirectory"] = "@prefix@/lib/sdrpp/plugins";
+ defConfig["resourcesDirectory"] = "@prefix@/share/sdrpp";
#endif
// Load config
@@ -290,6 +290,10 @@ int sdrpp_main(int argc, char *argv[]) {
int winHeight = core::configManager.conf["windowSize"]["h"];
maximized = core::configManager.conf["maximized"];
std::string resDir = core::configManager.conf["resourcesDirectory"];
+ {
+ std::size_t pos = resDir.find("@prefix@");
+ if (pos != std::string::npos) resDir.replace(pos, 8, INSTALL_PREFIX);
+ }
json bandColors = core::configManager.conf["bandColors"];
core::configManager.release();
diff --git a/core/src/gui/main_window.cpp b/core/src/gui/main_window.cpp
index 954dbd6..52f0eed 100644
--- a/core/src/gui/main_window.cpp
+++ b/core/src/gui/main_window.cpp
@@ -44,6 +44,12 @@ void MainWindow::init() {
json menuElements = core::configManager.conf["menuElements"];
std::string modulesDir = core::configManager.conf["modulesDirectory"];
std::string resourcesDir = core::configManager.conf["resourcesDirectory"];
+ {
+ std::size_t pos = modulesDir.find("@prefix@");
+ if (pos != std::string::npos) modulesDir.replace(pos, 8, INSTALL_PREFIX);
+ pos = resourcesDir.find("@prefix@");
+ if (pos != std::string::npos) resourcesDir.replace(pos, 8, INSTALL_PREFIX);
+ }
core::configManager.release();
// Load menu elements
--
2.33.0

View file

@ -19315,7 +19315,9 @@ with pkgs;
sdrplay = callPackage ../applications/radio/sdrplay {};
sdrpp = callPackage ../applications/radio/sdrpp { };
sdrpp = callPackage ../applications/radio/sdrpp {
inherit (darwin.apple_sdk.frameworks) AppKit;
};
sblim-sfcc = callPackage ../development/libraries/sblim-sfcc {};