summary refs log tree commit diff
path: root/pkgs/applications/radio/soapysdr/default.nix
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2023-09-14 11:31:01 +0000
committerAlyssa Ross <hi@alyssa.is>2023-09-14 11:31:01 +0000
commit4a027948f943c5e81d32b1ca70a86aa64cb7bae3 (patch)
tree332a139a9dc30c492425e987c172fc7d15325590 /pkgs/applications/radio/soapysdr/default.nix
parentd8be5d0c710412b5187815b52c2ddcc6661466ea (diff)
parent12aa32e71e41eb2fbf3d59db9eaacc6bedacf877 (diff)
downloadnixpkgs-4a027948f943c5e81d32b1ca70a86aa64cb7bae3.tar
nixpkgs-4a027948f943c5e81d32b1ca70a86aa64cb7bae3.tar.gz
nixpkgs-4a027948f943c5e81d32b1ca70a86aa64cb7bae3.tar.bz2
nixpkgs-4a027948f943c5e81d32b1ca70a86aa64cb7bae3.tar.lz
nixpkgs-4a027948f943c5e81d32b1ca70a86aa64cb7bae3.tar.xz
nixpkgs-4a027948f943c5e81d32b1ca70a86aa64cb7bae3.tar.zst
nixpkgs-4a027948f943c5e81d32b1ca70a86aa64cb7bae3.zip
Merge remote-tracking branch 'origin/staging-next' into staging
Conflicts:
	pkgs/applications/radio/soapysdr/default.nix
Diffstat (limited to 'pkgs/applications/radio/soapysdr/default.nix')
-rw-r--r--pkgs/applications/radio/soapysdr/default.nix97
1 files changed, 57 insertions, 40 deletions
diff --git a/pkgs/applications/radio/soapysdr/default.nix b/pkgs/applications/radio/soapysdr/default.nix
index 201a5055e60..ee03d67d598 100644
--- a/pkgs/applications/radio/soapysdr/default.nix
+++ b/pkgs/applications/radio/soapysdr/default.nix
@@ -1,64 +1,81 @@
-{ stdenv, lib, lndir, makeWrapper
-, fetchFromGitHub, cmake
-, libusb-compat-0_1, pkg-config
+{ stdenv
+, lib
+, fetchFromGitHub
+, fetchpatch
+, cmake
+, pkg-config
+, makeWrapper
+, libusb-compat-0_1
+, ncurses
 , usePython ? false
 , python ? null
-, ncurses, swig2
-, extraPackages ? []
-, testers
+, swig2
+, extraPackages ? [ ]
 , buildPackages
+, testers
 }:
 
-let
-
-  version = "0.8.1";
-  modulesVersion = with lib; versions.major version + "." + versions.minor version;
-  modulesPath = "lib/SoapySDR/modules" + modulesVersion;
-  extraPackagesSearchPath = lib.makeSearchPath modulesPath extraPackages;
-
-in stdenv.mkDerivation (finalAttrs: {
+stdenv.mkDerivation (finalAttrs: {
   pname = "soapysdr";
-  inherit version;
+  version = "0.8.1";
 
   src = fetchFromGitHub {
     owner = "pothosware";
     repo = "SoapySDR";
-    rev = "soapy-sdr-${version}";
+    rev = "soapy-sdr-${finalAttrs.version}";
     sha256 = "19f2x0pkxvf9figa0pl6xqlcz8fblvqb19mcnj632p0l8vk6qdv2";
   };
 
   patches = [
-    # see https://github.com/pothosware/SoapySDR/issues/352 for upstream issue
-    ./fix-pkgconfig.patch
+    # Fix for https://github.com/pothosware/SoapySDR/issues/352
+    (fetchpatch {
+      url = "https://github.com/pothosware/SoapySDR/commit/10c05b3e52caaa421147d6b4623eccd3fc3be3f4.patch";
+      hash = "sha256-D7so6NSZiU6SXbzns04Q4RjSZW0FJ+MYobvvVpVMjws=";
+    })
   ];
 
-  nativeBuildInputs = [ cmake makeWrapper pkg-config ];
-  buildInputs = [ libusb-compat-0_1 ncurses ]
-    ++ lib.optionals usePython [ python swig2 ];
-
-  propagatedBuildInputs = lib.optional usePython python.pkgs.numpy;
+  nativeBuildInputs = [
+    cmake
+    pkg-config
+    makeWrapper
+  ];
+  buildInputs = [
+    libusb-compat-0_1
+    ncurses
+  ] ++ lib.optionals usePython [
+    python
+    swig2
+  ];
 
-  cmakeFlags = lib.optional usePython "-DUSE_PYTHON_CONFIG=ON";
+  propagatedBuildInputs = lib.optionals usePython [
+    python.pkgs.numpy
+  ];
 
-  # https://github.com/pothosware/SoapySDR/issues/352
-  postPatch = ''
-    substituteInPlace lib/SoapySDR.in.pc \
-      --replace '$'{exec_prefix}/@CMAKE_INSTALL_LIBDIR@ @CMAKE_INSTALL_FULL_LIBDIR@ \
-      --replace '$'{prefix}/@CMAKE_INSTALL_INCLUDEDIR@ @CMAKE_INSTALL_FULL_INCLUDEDIR@
-  '';
+  cmakeFlags = lib.optionals usePython [
+    "-DUSE_PYTHON_CONFIG=ON"
+  ];
 
-  postFixup = lib.optionalString (lib.length extraPackages != 0) ''
+  postFixup = lib.optionalString (extraPackages != [ ]) (
     # Join all plugins via symlinking
-    for i in ${toString extraPackages}; do
-      ${buildPackages.xorg.lndir}/bin/lndir -silent $i $out
-    done
-    # Needed for at least the remote plugin server
-    for file in $out/bin/*; do
-        wrapProgram "$file" --prefix SOAPY_SDR_PLUGIN_PATH : ${lib.escapeShellArg extraPackagesSearchPath}
-    done
-  '';
+    lib.pipe extraPackages [
+      (map (pkg: ''
+        ${buildPackages.xorg.lndir}/bin/lndir -silent ${pkg} $out
+      ''))
+      lib.concatStrings
+    ] + ''
+      # Needed for at least the remote plugin server
+      for file in $out/bin/*; do
+          wrapProgram "$file" --prefix SOAPY_SDR_PLUGIN_PATH : ${lib.escapeShellArg (
+            lib.makeSearchPath finalAttrs.passthru.searchPath extraPackages
+          )}
+      done
+    ''
+  );
 
-  passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
+  passthru = {
+    tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
+    searchPath = "lib/SoapySDR/modules${lib.versions.majorMinor finalAttrs.version}";
+  };
 
   meta = with lib; {
     homepage = "https://github.com/pothosware/SoapySDR";