gnuradioMinimal.pkgs.osmosdr: make it possible to disable features (#433777)
This commit is contained in:
@@ -240,6 +240,22 @@
|
||||
|
||||
- We now use the upstream wrapper script for Gradle, supporting both the `JAVA_HOME` and `GRADLE_OPTS` environment variables.
|
||||
|
||||
- `gnuradio`: Overriding the `.pkgs` package set is now possible with a `packageOverrides` function, like with `python.pkgs` and other language-specific package sets.
|
||||
Example:
|
||||
|
||||
```nix
|
||||
gnuradioMinimal.override {
|
||||
packageOverrides = grSelf: grSuper: {
|
||||
osmosdr = grSuper.osmosdr.override {
|
||||
airspy = null;
|
||||
hackrf = null;
|
||||
libbladeRF = null;
|
||||
soapysdr-with-plugins = null;
|
||||
};
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
## Nixpkgs Library {#sec-nixpkgs-release-26.05-lib}
|
||||
|
||||
<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
],
|
||||
# Allow to add whatever you want to the wrapper
|
||||
extraMakeWrapperArgs ? [ ],
|
||||
packageOverrides ? (self: super: { }),
|
||||
}:
|
||||
|
||||
let
|
||||
@@ -191,7 +192,12 @@ let
|
||||
);
|
||||
|
||||
packages = import ../../../top-level/gnuradio-packages.nix {
|
||||
inherit lib stdenv newScope;
|
||||
inherit
|
||||
lib
|
||||
stdenv
|
||||
newScope
|
||||
packageOverrides
|
||||
;
|
||||
gnuradio = unwrapped;
|
||||
};
|
||||
passthru = unwrapped.passthru // {
|
||||
|
||||
@@ -2,11 +2,14 @@
|
||||
gnuradio,
|
||||
volk,
|
||||
uhdMinimal,
|
||||
packageOverrides ? (self: super: { }),
|
||||
unwrappedFeaturesOverride ? { },
|
||||
}:
|
||||
# A build without gui components and other utilities not needed for end user
|
||||
# libraries
|
||||
gnuradio.override {
|
||||
doWrap = false;
|
||||
inherit packageOverrides;
|
||||
unwrapped = gnuradio.unwrapped.override {
|
||||
volk = volk.override {
|
||||
# So it will not reference python
|
||||
@@ -26,6 +29,7 @@ gnuradio.override {
|
||||
# Doesn't make it reference python eventually, but makes reverse
|
||||
# dependencies require python to use cmake files of GR.
|
||||
gr-ctrlport = false;
|
||||
};
|
||||
}
|
||||
// unwrappedFeaturesOverride;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -7,32 +7,44 @@ mkDerivation:
|
||||
|
||||
args:
|
||||
|
||||
# Check if it's supposed to not get built for the current gnuradio version
|
||||
if (builtins.hasAttr "disabled" args) && args.disabled then
|
||||
let
|
||||
name = args.name or "${args.pname}";
|
||||
in
|
||||
throw "Package ${name} is incompatible with GNURadio ${unwrapped.versionAttr.major}"
|
||||
else
|
||||
let
|
||||
# Common validation and processing logic
|
||||
processArgs =
|
||||
args:
|
||||
# Check if it's supposed to not get built for the current gnuradio version
|
||||
if (builtins.hasAttr "disabled" args) && args.disabled then
|
||||
let
|
||||
name = args.name or "${args.pname}";
|
||||
in
|
||||
throw "Package ${name} is incompatible with GNURadio ${unwrapped.versionAttr.major}"
|
||||
else
|
||||
|
||||
if builtins.hasAttr "disabledForGRafter" args then
|
||||
throw ''
|
||||
`disabledForGRafter` is superseded by `disabled`.
|
||||
Use `disabled = gnuradioAtLeast "${args.disabledForGRafter}";` instead.
|
||||
''
|
||||
else
|
||||
if builtins.hasAttr "disabledForGRafter" args then
|
||||
throw ''
|
||||
`disabledForGRafter` is superseded by `disabled`.
|
||||
Use `disabled = gnuradioAtLeast "${args.disabledForGRafter}";` instead.
|
||||
''
|
||||
else
|
||||
|
||||
let
|
||||
args_ = {
|
||||
enableParallelBuilding = args.enableParallelBuilding or true;
|
||||
nativeBuildInputs = (args.nativeBuildInputs or [ ]);
|
||||
# We add gnuradio and volk itself by default - most gnuradio based packages
|
||||
# will not consider it a dependency worth mentioning and it will almost
|
||||
# always be needed
|
||||
buildInputs = (args.buildInputs or [ ]) ++ [
|
||||
unwrapped
|
||||
unwrapped.volk
|
||||
];
|
||||
};
|
||||
in
|
||||
mkDerivation (args // args_)
|
||||
let
|
||||
args_ = {
|
||||
enableParallelBuilding = args.enableParallelBuilding or true;
|
||||
nativeBuildInputs = (args.nativeBuildInputs or [ ]);
|
||||
# We add gnuradio and volk itself by default - most gnuradio based packages
|
||||
# will not consider it a dependency worth mentioning and it will almost
|
||||
# always be needed
|
||||
buildInputs = (args.buildInputs or [ ]) ++ [
|
||||
unwrapped
|
||||
unwrapped.volk
|
||||
];
|
||||
};
|
||||
in
|
||||
args // args_;
|
||||
|
||||
in
|
||||
if builtins.isFunction args then
|
||||
# Function form: args is (finalAttrs -> attrset)
|
||||
mkDerivation (finalAttrs: processArgs (args finalAttrs))
|
||||
else
|
||||
# Attrset form: args is attrset
|
||||
mkDerivation (processArgs args)
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
mkDerivation,
|
||||
gnuradioAtLeast,
|
||||
fetchgit,
|
||||
fetchpatch,
|
||||
gnuradio,
|
||||
|
||||
# native
|
||||
cmake,
|
||||
pkg-config,
|
||||
|
||||
# buildInputs
|
||||
logLib,
|
||||
libsndfile,
|
||||
mpir,
|
||||
@@ -22,16 +26,16 @@
|
||||
libbladeRF,
|
||||
rtl-sdr,
|
||||
soapysdr-with-plugins,
|
||||
gnuradioAtLeast,
|
||||
features ? { },
|
||||
}:
|
||||
|
||||
mkDerivation rec {
|
||||
mkDerivation (finalAttrs: {
|
||||
pname = "gr-osmosdr";
|
||||
version = "0.2.6";
|
||||
|
||||
src = fetchgit {
|
||||
url = "https://gitea.osmocom.org/sdr/gr-osmosdr";
|
||||
rev = "v${version}";
|
||||
rev = "v${finalAttrs.version}";
|
||||
hash = "sha256-jCUzBY1pYiEtcRQ97t9F6uEMVYw2NU0eoB5Xc2H6pGQ=";
|
||||
};
|
||||
|
||||
@@ -58,12 +62,8 @@ mkDerivation rec {
|
||||
fftwFloat
|
||||
gmp
|
||||
icu
|
||||
airspy
|
||||
hackrf
|
||||
libbladeRF
|
||||
rtl-sdr
|
||||
soapysdr-with-plugins
|
||||
]
|
||||
++ finalAttrs.finalPackage.passthru.enabledFeaturesDeps
|
||||
++ lib.optionals (gnuradio.hasFeature "gr-blocks") [
|
||||
libsndfile
|
||||
]
|
||||
@@ -80,7 +80,8 @@ mkDerivation rec {
|
||||
];
|
||||
cmakeFlags = [
|
||||
(if (gnuradio.hasFeature "python-support") then "-DENABLE_PYTHON=ON" else "-DENABLE_PYTHON=OFF")
|
||||
];
|
||||
]
|
||||
++ finalAttrs.finalPackage.passthru.enabledFeaturesCmakeFlags;
|
||||
nativeBuildInputs = [
|
||||
cmake
|
||||
pkg-config
|
||||
@@ -89,6 +90,25 @@ mkDerivation rec {
|
||||
python.pkgs.mako
|
||||
python
|
||||
];
|
||||
passthru = {
|
||||
featuresDeps = {
|
||||
# Other features don't have dependencies but can still be disabled in the
|
||||
# `features` argument.
|
||||
airspy = [ airspy ];
|
||||
bladerf = [ libbladeRF ];
|
||||
hackrf = [ hackrf ];
|
||||
rtl = [ rtl-sdr ];
|
||||
soapy = [ soapysdr-with-plugins ];
|
||||
};
|
||||
enabledFeaturesDeps = lib.pipe finalAttrs.finalPackage.passthru.featuresDeps [
|
||||
(lib.filterAttrs (name: deps: features.${name} or true))
|
||||
lib.attrValues
|
||||
lib.flatten
|
||||
];
|
||||
enabledFeaturesCmakeFlags = lib.mapAttrsToList (
|
||||
feat: val: lib.cmakeBool "ENABLE_${lib.toUpper feat}" val
|
||||
) features;
|
||||
};
|
||||
|
||||
meta = {
|
||||
description = "Gnuradio block for OsmoSDR and rtl-sdr";
|
||||
@@ -97,4 +117,4 @@ mkDerivation rec {
|
||||
maintainers = with lib.maintainers; [ bjornfor ];
|
||||
platforms = lib.platforms.unix;
|
||||
};
|
||||
}
|
||||
})
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
stdenv,
|
||||
newScope,
|
||||
gnuradio, # unwrapped gnuradio
|
||||
packageOverrides,
|
||||
}:
|
||||
|
||||
lib.makeScope newScope (
|
||||
@@ -34,21 +35,21 @@ lib.makeScope newScope (
|
||||
inherit (gnuradio) uhd;
|
||||
}
|
||||
);
|
||||
|
||||
# Base package set without overrides
|
||||
basePackages = {
|
||||
inherit callPackage mkDerivation mkDerivationWith;
|
||||
|
||||
bladeRF = callPackage ../development/gnuradio-modules/bladeRF/default.nix { };
|
||||
|
||||
lora_sdr = callPackage ../development/gnuradio-modules/lora_sdr/default.nix { };
|
||||
|
||||
osmosdr = callPackage ../development/gnuradio-modules/osmosdr/default.nix { };
|
||||
|
||||
fosphor = callPackage ../development/gnuradio-modules/fosphor/default.nix { };
|
||||
|
||||
gr-difi = callPackage ../development/gnuradio-modules/gr-difi/default.nix { };
|
||||
};
|
||||
in
|
||||
{
|
||||
|
||||
inherit callPackage mkDerivation mkDerivationWith;
|
||||
|
||||
### Packages
|
||||
|
||||
bladeRF = callPackage ../development/gnuradio-modules/bladeRF/default.nix { };
|
||||
|
||||
lora_sdr = callPackage ../development/gnuradio-modules/lora_sdr/default.nix { };
|
||||
|
||||
osmosdr = callPackage ../development/gnuradio-modules/osmosdr/default.nix { };
|
||||
|
||||
fosphor = callPackage ../development/gnuradio-modules/fosphor/default.nix { };
|
||||
|
||||
gr-difi = callPackage ../development/gnuradio-modules/gr-difi/default.nix { };
|
||||
}
|
||||
basePackages // (packageOverrides self basePackages)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user