2021-01-15 06:42:41 +01:00
|
|
|
{ lib, stdenv
|
2020-10-05 11:04:49 +02:00
|
|
|
, python
|
|
|
|
, qt
|
|
|
|
, gtk
|
|
|
|
, removeReferencesTo
|
|
|
|
, featuresInfo
|
|
|
|
, features
|
2023-10-03 14:23:48 +02:00
|
|
|
, version
|
2020-10-05 11:04:49 +02:00
|
|
|
, sourceSha256
|
2022-12-18 01:39:44 +01:00
|
|
|
# If overridden. No need to set default values, as they are given defaults in
|
2020-10-05 11:04:49 +02:00
|
|
|
# the main expressions
|
|
|
|
, overrideSrc
|
|
|
|
, fetchFromGitHub
|
|
|
|
}:
|
|
|
|
|
2023-10-03 14:23:48 +02:00
|
|
|
let
|
|
|
|
# Check if a feature is enabled, while defaulting to true if feat is not
|
|
|
|
# specified.
|
|
|
|
hasFeature = feat: (
|
|
|
|
if builtins.hasAttr feat features then
|
|
|
|
features.${feat}
|
|
|
|
else
|
|
|
|
true
|
2020-10-05 11:04:49 +02:00
|
|
|
);
|
2023-10-03 14:23:48 +02:00
|
|
|
versionAttr = {
|
|
|
|
major = builtins.concatStringsSep "." (lib.take 2 (lib.splitVersion version));
|
|
|
|
minor = builtins.elemAt (lib.splitVersion version) 2;
|
|
|
|
patch = builtins.elemAt (lib.splitVersion version) 3;
|
|
|
|
};
|
|
|
|
in {
|
2020-10-05 11:04:49 +02:00
|
|
|
src = if overrideSrc != {} then
|
|
|
|
overrideSrc
|
|
|
|
else
|
|
|
|
fetchFromGitHub {
|
|
|
|
repo = "gnuradio";
|
|
|
|
owner = "gnuradio";
|
|
|
|
rev = "v${version}";
|
|
|
|
sha256 = sourceSha256;
|
|
|
|
}
|
|
|
|
;
|
|
|
|
nativeBuildInputs = lib.flatten (lib.mapAttrsToList (
|
|
|
|
feat: info: (
|
2023-02-14 19:11:59 +01:00
|
|
|
lib.optionals (hasFeature feat) (
|
|
|
|
(lib.optionals (builtins.hasAttr "native" info) info.native) ++
|
|
|
|
(lib.optionals (builtins.hasAttr "pythonNative" info) info.pythonNative)
|
|
|
|
)
|
2020-10-05 11:04:49 +02:00
|
|
|
)
|
|
|
|
) featuresInfo);
|
|
|
|
buildInputs = lib.flatten (lib.mapAttrsToList (
|
|
|
|
feat: info: (
|
2023-02-14 19:11:59 +01:00
|
|
|
lib.optionals (hasFeature feat) (
|
|
|
|
(lib.optionals (builtins.hasAttr "runtime" info) info.runtime) ++
|
|
|
|
(lib.optionals (builtins.hasAttr "pythonRuntime" info) info.pythonRuntime)
|
|
|
|
)
|
2020-10-05 11:04:49 +02:00
|
|
|
)
|
|
|
|
) featuresInfo);
|
|
|
|
cmakeFlags = lib.mapAttrsToList (
|
|
|
|
feat: info: (
|
|
|
|
if feat == "basic" then
|
|
|
|
# Abuse this unavoidable "iteration" to set this flag which we want as
|
|
|
|
# well - it means: Don't turn on features just because their deps are
|
|
|
|
# satisfied, let only our cmakeFlags decide.
|
|
|
|
"-DENABLE_DEFAULT=OFF"
|
|
|
|
else
|
2021-10-21 22:59:37 +02:00
|
|
|
if hasFeature feat then
|
2020-10-05 11:04:49 +02:00
|
|
|
"-DENABLE_${info.cmakeEnableFlag}=ON"
|
|
|
|
else
|
|
|
|
"-DENABLE_${info.cmakeEnableFlag}=OFF"
|
|
|
|
)) featuresInfo
|
|
|
|
;
|
|
|
|
disallowedReferences = [
|
|
|
|
# TODO: Should this be conditional?
|
|
|
|
stdenv.cc
|
|
|
|
stdenv.cc.cc
|
|
|
|
]
|
|
|
|
# If python-support is disabled, we probably don't want it referenced
|
2021-10-21 22:59:37 +02:00
|
|
|
++ lib.optionals (!hasFeature "python-support") [ python ]
|
2020-10-05 11:04:49 +02:00
|
|
|
;
|
|
|
|
# Gcc references from examples
|
|
|
|
stripDebugList = [ "lib" "bin" ]
|
2021-10-21 22:59:37 +02:00
|
|
|
++ lib.optionals (hasFeature "gr-audio") [ "share/gnuradio/examples/audio" ]
|
|
|
|
++ lib.optionals (hasFeature "gr-uhd") [ "share/gnuradio/examples/uhd" ]
|
|
|
|
++ lib.optionals (hasFeature "gr-qtgui") [ "share/gnuradio/examples/qt-gui" ]
|
2020-10-05 11:04:49 +02:00
|
|
|
;
|
2021-01-24 10:19:10 +01:00
|
|
|
postInstall = ""
|
2020-10-05 11:04:49 +02:00
|
|
|
# Gcc references
|
2021-10-21 22:59:37 +02:00
|
|
|
+ lib.optionalString (hasFeature "gnuradio-runtime") ''
|
2022-10-25 02:31:44 +02:00
|
|
|
${removeReferencesTo}/bin/remove-references-to -t ${stdenv.cc} $(readlink -f $out/lib/libgnuradio-runtime${stdenv.hostPlatform.extensions.sharedLibrary})
|
|
|
|
''
|
|
|
|
# Clang references in InstalledDir
|
|
|
|
+ lib.optionalString (hasFeature "gnuradio-runtime" && stdenv.isDarwin) ''
|
|
|
|
${removeReferencesTo}/bin/remove-references-to -t ${stdenv.cc.cc} $(readlink -f $out/lib/libgnuradio-runtime${stdenv.hostPlatform.extensions.sharedLibrary})
|
2020-10-05 11:04:49 +02:00
|
|
|
''
|
|
|
|
;
|
|
|
|
# NOTE: Outputs are disabled due to upstream not using GNU InstallDIrs cmake
|
|
|
|
# module. It's not that bad since it's a development package for most
|
|
|
|
# purposes. If closure size needs to be reduced, features should be disabled
|
|
|
|
# via an override.
|
|
|
|
passthru = {
|
|
|
|
inherit
|
|
|
|
hasFeature
|
|
|
|
versionAttr
|
|
|
|
features
|
|
|
|
featuresInfo
|
|
|
|
python
|
|
|
|
;
|
2024-01-16 23:19:41 +01:00
|
|
|
gnuradioOlder = lib.versionOlder versionAttr.major;
|
|
|
|
gnuradioAtLeast = lib.versionAtLeast versionAttr.major;
|
2021-10-21 22:59:37 +02:00
|
|
|
} // lib.optionalAttrs (hasFeature "gr-qtgui") {
|
2020-12-15 11:31:32 +01:00
|
|
|
inherit qt;
|
2021-10-21 22:59:37 +02:00
|
|
|
} // lib.optionalAttrs (hasFeature "gnuradio-companion") {
|
2020-12-15 11:31:32 +01:00
|
|
|
inherit gtk;
|
2020-10-05 11:04:49 +02:00
|
|
|
};
|
|
|
|
# Wrapping is done with an external wrapper
|
|
|
|
dontWrapPythonPrograms = true;
|
2021-01-12 12:50:23 +01:00
|
|
|
dontWrapQtApps = true;
|
2023-10-03 14:29:19 +02:00
|
|
|
# On darwin, it requires playing with DYLD_FALLBACK_LIBRARY_PATH to make if
|
|
|
|
# find libgnuradio-runtim.3.*.dylib .
|
|
|
|
doCheck = !stdenv.isDarwin;
|
|
|
|
preCheck = ''
|
|
|
|
export HOME=$(mktemp -d)
|
|
|
|
export QT_QPA_PLATFORM=offscreen
|
|
|
|
export QT_PLUGIN_PATH="${qt.qtbase.bin}/${qt.qtbase.qtPluginPrefix}"
|
|
|
|
'';
|
2020-10-05 11:04:49 +02:00
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "Software Defined Radio (SDR) software";
|
2024-03-19 03:14:51 +01:00
|
|
|
mainProgram = "gnuradio-config-info";
|
2020-10-05 11:04:49 +02:00
|
|
|
longDescription = ''
|
|
|
|
GNU Radio is a free & open-source software development toolkit that
|
|
|
|
provides signal processing blocks to implement software radios. It can be
|
|
|
|
used with readily-available low-cost external RF hardware to create
|
|
|
|
software-defined radios, or without hardware in a simulation-like
|
|
|
|
environment. It is widely used in hobbyist, academic and commercial
|
|
|
|
environments to support both wireless communications research and
|
|
|
|
real-world radio systems.
|
|
|
|
'';
|
|
|
|
homepage = "https://www.gnuradio.org";
|
|
|
|
license = licenses.gpl3;
|
|
|
|
platforms = platforms.unix;
|
2022-10-25 17:18:23 +02:00
|
|
|
maintainers = with maintainers; [ doronbehar bjornfor fpletz jiegec ];
|
2020-10-05 11:04:49 +02:00
|
|
|
};
|
|
|
|
}
|