Unverified Commit 8802d671 authored by Doron Behar's avatar Doron Behar Committed by GitHub
Browse files

gnuradioMinimal.pkgs.osmosdr: make it possible to disable features (#433777)

parents 606ca34e 3b6d3ac7
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -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. -->
+7 −1
Original line number Diff line number Diff line
@@ -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 // {
+5 −1
Original line number Diff line number Diff line
@@ -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;
  };
}
+39 −27
Original line number Diff line number Diff line
@@ -7,6 +7,10 @@ mkDerivation:

args:

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
@@ -35,4 +39,12 @@ else
          ];
        };
      in
  mkDerivation (args // args_)
      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)
+31 −11
Original line number Diff line number Diff line
{
  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;
  };
}
})
Loading