uhd: fix Darwin build (fixes also Gnuradio build) (#481933)

This commit is contained in:
Doron Behar
2026-01-22 13:11:39 +00:00
committed by GitHub
4 changed files with 122 additions and 129 deletions
+14 -21
View File
@@ -310,27 +310,20 @@ stdenv.mkDerivation (
# Not accepted upstream, see https://github.com/gnuradio/gnuradio/pull/5227
./modtool-newmod-permissions.patch
];
passthru =
shared.passthru
// {
# Deps that are potentially overridden and are used inside GR plugins - the same version must
inherit
boost
volk
;
# Used by many gnuradio modules, the same attribute is present in
# previous gnuradio versions where there it's log4cpp.
logLib = spdlog;
}
// lib.optionalAttrs (hasFeature "gr-uhd") {
inherit uhd;
}
// lib.optionalAttrs (hasFeature "gr-pdu") {
inherit libiio libad9361;
}
// lib.optionalAttrs (hasFeature "gr-qtgui") {
inherit (libsForQt5) qwt;
};
passthru = shared.passthru // {
# Deps that are potentially overridden and are used inside GR plugins - the same version must
inherit
uhd
boost
volk
libiio
libad9361
;
# Used by many gnuradio modules, the same attribute is present in
# previous gnuradio versions where there it's log4cpp.
logLib = spdlog;
inherit (libsForQt5) qwt;
};
postInstall =
shared.postInstall
+61 -70
View File
@@ -50,6 +50,8 @@
soapyplutosdr
soapyremote
soapyrtlsdr
]
++ lib.optionals (unwrapped.hasFeature "gr-uhd") [
soapyuhd
],
# Allow to add whatever you want to the wrapper
@@ -62,10 +64,14 @@ let
pythonPkgs =
extraPythonPackages
++ [ (unwrapped.python.pkgs.toPythonModule unwrapped) ]
++ unwrapped.passthru.uhd.pythonPath
++ lib.optionals (unwrapped.passthru.uhd.pythonPath != [ ]) [
(unwrapped.python.pkgs.toPythonModule unwrapped.passthru.uhd)
]
++ lib.optionals (unwrapped.hasFeature "gr-uhd") (
unwrapped.passthru.uhd.pythonPath
# Check if uhd was built with python support, which means it should
# be added as a python module too.
++ lib.optionals (unwrapped.passthru.uhd.pythonPath != [ ]) [
(unwrapped.python.pkgs.toPythonModule unwrapped.passthru.uhd)
]
)
# Add the extraPackages as python modules as well
++ (map unwrapped.python.pkgs.toPythonModule extraPackages)
++ lib.flatten (
@@ -81,35 +87,31 @@ let
pname = unwrapped.pname + "-wrapped";
inherit (unwrapped) outputs version;
makeWrapperArgs = builtins.concatStringsSep " " (
[
]
# Emulating wrapGAppsHook3 & wrapQtAppsHook working together
++
lib.optionals ((unwrapped.hasFeature "gnuradio-companion") || (unwrapped.hasFeature "gr-qtgui"))
[
"--prefix"
"XDG_DATA_DIRS"
":"
"$out/share"
"--prefix"
"XDG_DATA_DIRS"
":"
"$out/share/gsettings-schemas/${pname}"
"--prefix"
"XDG_DATA_DIRS"
":"
"${gsettings-desktop-schemas}/share/gsettings-schemas/${gsettings-desktop-schemas.name}"
"--prefix"
"XDG_DATA_DIRS"
":"
"${hicolor-icon-theme}/share"
# Needs to run `gsettings` on startup, see:
# https://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg1764890.html
"--prefix"
"PATH"
":"
"${lib.getBin glib}/bin"
]
lib.optionals ((unwrapped.hasFeature "gnuradio-companion") || (unwrapped.hasFeature "gr-qtgui")) [
"--prefix"
"XDG_DATA_DIRS"
":"
"$out/share"
"--prefix"
"XDG_DATA_DIRS"
":"
"$out/share/gsettings-schemas/${pname}"
"--prefix"
"XDG_DATA_DIRS"
":"
"${gsettings-desktop-schemas}/share/gsettings-schemas/${gsettings-desktop-schemas.name}"
"--prefix"
"XDG_DATA_DIRS"
":"
"${hicolor-icon-theme}/share"
# Needs to run `gsettings` on startup, see:
# https://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg1764890.html
"--prefix"
"PATH"
":"
"${lib.getBin glib}/bin"
]
++ lib.optionals (unwrapped.hasFeature "gnuradio-companion") [
"--set"
"GDK_PIXBUF_MODULE_FILE"
@@ -157,45 +159,34 @@ let
":"
"${lib.makeSearchPath soapysdr.passthru.searchPath extraSoapySdrPackages}"
]
++
lib.optionals (unwrapped.hasFeature "gr-qtgui")
# 3.7 builds with qt4
(
if lib.versionAtLeast unwrapped.versionAttr.major "3.8" then
[
"--prefix"
"QT_PLUGIN_PATH"
":"
"${lib.makeSearchPath unwrapped.qt.qtbase.qtPluginPrefix (
map lib.getBin (
[
unwrapped.qt.qtbase
]
++ lib.optionals stdenv.hostPlatform.isLinux [
unwrapped.qt.qtwayland
]
)
)}"
"--prefix"
"QML2_IMPORT_PATH"
":"
"${lib.makeSearchPath unwrapped.qt.qtbase.qtQmlPrefix (
map lib.getBin (
[
unwrapped.qt.qtbase
]
++ lib.optionals stdenv.hostPlatform.isLinux [
unwrapped.qt.qtwayland
]
)
)}"
]
else
# Add here qt4 related environment for 3.7?
[
]
++ lib.optionals (unwrapped.hasFeature "gr-qtgui") [
"--prefix"
"QT_PLUGIN_PATH"
":"
"${lib.makeSearchPath unwrapped.qt.qtbase.qtPluginPrefix (
map lib.getBin (
[
unwrapped.qt.qtbase
]
++ lib.optionals stdenv.hostPlatform.isLinux [
unwrapped.qt.qtwayland
]
)
)}"
"--prefix"
"QML2_IMPORT_PATH"
":"
"${lib.makeSearchPath unwrapped.qt.qtbase.qtQmlPrefix (
map lib.getBin (
[
unwrapped.qt.qtbase
]
++ lib.optionals stdenv.hostPlatform.isLinux [
unwrapped.qt.qtwayland
]
)
)}"
]
++ extraMakeWrapperArgs
);
+2 -1
View File
@@ -85,7 +85,7 @@ stdenv.mkDerivation (finalAttrs: {
# Tests that hang up in the Darwin sandbox
"SecurityTest"
"SecurityFromBufferTest"
"python_test"
"PythonThriftTNonblockingServer"
# fails on hydra, passes locally
"concurrency_test"
@@ -95,6 +95,7 @@ stdenv.mkDerivation (finalAttrs: {
"TInterruptTest"
"TServerIntegrationTest"
"processor"
"processor_test"
"TNonblockingServerTest"
"TNonblockingSSLServerTest"
"StressTest"
+45 -37
View File
@@ -1,8 +1,7 @@
{
lib,
stdenv,
substitute,
fetchpatch,
llvmPackages_20,
fetchurl,
fetchFromGitHub,
cmake,
@@ -36,15 +35,23 @@
let
inherit (lib) optionals cmakeBool;
stdenv' = (
# Fix a compilation issue on Darwin, that upstream is aware of:
# https://github.com/EttusResearch/uhd/issues/881
if stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64 then
llvmPackages_20.stdenv
else
stdenv
);
in
stdenv.mkDerivation (finalAttrs: {
stdenv'.mkDerivation (finalAttrs: {
pname = "uhd";
# NOTE: Use the following command to update the package, and the uhdImageSrc attribute:
#
# nix-shell maintainers/scripts/update.nix --argstr package uhd --argstr commit true
#
version = "4.9.0.0";
version = "4.9.0.1";
outputs = [
"out"
@@ -57,41 +64,42 @@ stdenv.mkDerivation (finalAttrs: {
rev = "v${finalAttrs.version}";
# The updateScript relies on the `src` using `hash`, and not `sha256. To
# update the correct hash for the `src` vs the `uhdImagesSrc`
hash = "sha256-XA/ADJ0HjD6DxqFTVMwFa7tRgM56mHAEL+a0paWxKyM=";
hash = "sha256-AOZYCmkgsM09YORW7dVsPAwecXNZQOxOscJnVOlMoP0=";
};
# Firmware images are downloaded (pre-built) from the respective release on Github
uhdImagesSrc = fetchurl {
url = "https://github.com/EttusResearch/uhd/releases/download/v${finalAttrs.version}/uhd-images_${finalAttrs.version}.tar.xz";
# Please don't convert this to a hash, in base64, see comment near src's
# hash.
sha256 = "194gsmvn7gmwj7b1lw9sq0d0y0babbd0q1229qbb3qjc6f6m0p0y";
sha256 = "15ahcxb7hsylvdzzv0q0shd3wqm7p2y4kzbqk85cvsxbdklxhsvn";
};
# This are the minimum required Python dependencies, this attribute might
# be useful if you want to build a development environment with a python
# interpreter able to import the uhd module.
pythonPath =
optionals (enablePythonApi || enableUtils) [
python3.pkgs.numpy
python3.pkgs.setuptools
]
++ optionals enableUtils [
python3.pkgs.requests
python3.pkgs.six
/*
These deps are needed for the usrp_hwd.py utility, however even if they
would have been added here, the utility wouldn't have worked because it
depends on an old python library mprpc that is not supported for Python >
3.8. See also report upstream:
https://github.com/EttusResearch/uhd/issues/744
python3.pkgs.gevent
python3.pkgs.pyudev
python3.pkgs.pyroute2
*/
];
inherit (finalAttrs.finalPackage.passthru) pythonPath;
passthru = {
runtimePython = python3.withPackages (ps: finalAttrs.pythonPath);
runtimePython = python3.withPackages (ps: finalAttrs.finalPackage.passthru.pythonPath);
# This are the minimum required Python dependencies, this attribute might
# be useful if you want to build a development environment with a python
# interpreter able to import the uhd module.
pythonPath =
optionals (enablePythonApi || enableUtils) [
python3.pkgs.numpy
python3.pkgs.setuptools
]
++ optionals enableUtils [
python3.pkgs.requests
python3.pkgs.six
/*
These deps are needed for the usrp_hwd.py utility, however even if they
would have been added here, the utility wouldn't have worked because it
depends on an old python library mprpc that is not supported for Python >
3.8. See also report upstream:
https://github.com/EttusResearch/uhd/issues/744
python3.pkgs.gevent
python3.pkgs.pyudev
python3.pkgs.pyroute2
*/
];
updateScript = [
./update.sh
# Pass it this file name as argument
@@ -100,11 +108,11 @@ stdenv.mkDerivation (finalAttrs: {
};
cmakeFlags = [
"-DENABLE_LIBUHD=ON"
"-DENABLE_USB=ON"
(cmakeBool "ENABLE_LIBUHD" true)
(cmakeBool "ENABLE_USB" true)
# Regardless of doCheck, we want to build the tests to help us gain
# confident that the package is OK.
"-DENABLE_TESTS=ON"
(cmakeBool "ENABLE_TESTS" true)
(cmakeBool "ENABLE_EXAMPLES" enableExamples)
(cmakeBool "ENABLE_UTILS" enableUtils)
(cmakeBool "ENABLE_C_API" enableCApi)
@@ -148,7 +156,7 @@ stdenv.mkDerivation (finalAttrs: {
# ABI differences GCC 7.1
# /nix/store/wd6r25miqbk9ia53pp669gn4wrg9n9cj-gcc-7.3.0/include/c++/7.3.0/bits/vector.tcc:394:7: note: parameter passing for argument of type 'std::vector<uhd::range_t>::iterator {aka __gnu_cxx::__normal_iterator<uhd::range_t*, std::vector<uhd::range_t> >}' changed in GCC 7.1
]
++ optionals stdenv.hostPlatform.isAarch32 [
++ optionals stdenv'.hostPlatform.isAarch32 [
"-DCMAKE_CXX_FLAGS=-Wno-psabi"
];
@@ -181,7 +189,7 @@ stdenv.mkDerivation (finalAttrs: {
];
# many tests fails on darwin, according to ofborg
doCheck = !stdenv.hostPlatform.isDarwin;
doCheck = !stdenv'.hostPlatform.isDarwin;
doInstallCheck = true;
@@ -192,7 +200,7 @@ stdenv.mkDerivation (finalAttrs: {
"installFirmware"
"removeInstalledTests"
]
++ optionals (enableUtils && stdenv.hostPlatform.isLinux) [
++ optionals (enableUtils && stdenv'.hostPlatform.isLinux) [
"moveUdevRules"
];