Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1From a80a739163d2013ec400223a68a387f4f9297b2a Mon Sep 17 00:00:00 2001 2From: Nikolay Korotkiy <sikmir@gmail.com> 3Date: Fri, 29 Oct 2021 01:38:21 +0300 4Subject: [PATCH] Fix sdrpp breaking every time the package is rebuilt. 5 6On NixOS, the INSTALL_PREFIX changes on every rebuild to the package, but sdrpp 7fills it in as part of the default config and then installs that config 8to the users home folder. Fix this by not substituting @INSTALL_PREFIX@ in the 9default 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 15diff --git a/core/src/core.cpp b/core/src/core.cpp 16index 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 41diff --git a/core/src/gui/main_window.cpp b/core/src/gui/main_window.cpp 42index 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-- 592.33.0 60