From 9e0ed182aa86add5fecf6d575405687eb7c61f70 Mon Sep 17 00:00:00 2001 From: pmenke Date: Mon, 24 May 2021 17:12:31 +0200 Subject: [PATCH] sdrplay: init at 3.07.1 this adds support for software defined radio (SDR) devices by SDRplay. SDRplay provides an unfree binary library and api-service as well as a MIT licensed adapter library for SoapySDR for integration with many popular SDR applications. --- nixos/modules/module-list.nix | 1 + nixos/modules/services/misc/sdrplay.nix | 35 +++++++++++++ pkgs/applications/radio/sdrplay/default.nix | 51 +++++++++++++++++++ .../radio/soapysdrplay/default.nix | 29 +++++++++++ pkgs/top-level/all-packages.nix | 4 ++ 5 files changed, 120 insertions(+) create mode 100644 nixos/modules/services/misc/sdrplay.nix create mode 100644 pkgs/applications/radio/sdrplay/default.nix create mode 100644 pkgs/applications/radio/soapysdrplay/default.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index aa4e2ccc46bc..e51c833a01ca 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -547,6 +547,7 @@ ./services/misc/ripple-data-api.nix ./services/misc/serviio.nix ./services/misc/safeeyes.nix + ./services/misc/sdrplay.nix ./services/misc/sickbeard.nix ./services/misc/siproxd.nix ./services/misc/snapper.nix diff --git a/nixos/modules/services/misc/sdrplay.nix b/nixos/modules/services/misc/sdrplay.nix new file mode 100644 index 000000000000..2801108f0828 --- /dev/null +++ b/nixos/modules/services/misc/sdrplay.nix @@ -0,0 +1,35 @@ +{ config, lib, pkgs, ... }: +with lib; +{ + options.services.sdrplayApi = { + enable = mkOption { + default = false; + example = true; + description = '' + Whether to enable the SDRplay API service and udev rules. + + + To enable integration with SoapySDR and GUI applications like gqrx create an overlay containing + soapysdr-with-plugins = super.soapysdr.override { extraPackages = [ super.soapysdrplay ]; }; + + ''; + type = lib.types.bool; + }; + }; + + config = mkIf config.services.sdrplayApi.enable { + systemd.services.sdrplayApi = { + description = "SDRplay API Service"; + after = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + ExecStart = "${pkgs.sdrplay}/bin/sdrplay_apiService"; + DynamicUser = true; + Restart = "on-failure"; + RestartSec = "1s"; + }; + }; + services.udev.packages = [ pkgs.sdrplay ]; + + }; +} diff --git a/pkgs/applications/radio/sdrplay/default.nix b/pkgs/applications/radio/sdrplay/default.nix new file mode 100644 index 000000000000..d12b12ecc13c --- /dev/null +++ b/pkgs/applications/radio/sdrplay/default.nix @@ -0,0 +1,51 @@ +{ stdenv, lib, fetchurl, autoPatchelfHook, udev }: +let + arch = if stdenv.isx86_64 then "x86_64" + else if stdenv.isi686 then "i686" + else throw "unsupported architecture"; +in stdenv.mkDerivation rec { + name = "sdrplay"; + version = "3.07.1"; + + src = fetchurl { + url = "https://www.sdrplay.com/software/SDRplay_RSP_API-Linux-${version}.run"; + sha256 = "1a25c7rsdkcjxr7ffvx2lwj7fxdbslg9qhr8ghaq1r53rcrqgzmf"; + }; + + nativeBuildInputs = [ autoPatchelfHook ]; + + buildInputs = [ udev stdenv.cc.cc.lib ]; + + unpackPhase = '' + sh "$src" --noexec --target source + ''; + + sourceRoot = "source"; + + dontBuild = true; + + installPhase = '' + mkdir -p $out/{bin,lib,include,lib/udev/rules.d} + majorVersion="${lib.concatStringsSep "." (lib.take 1 (builtins.splitVersion version))}" + majorMinorVersion="${lib.concatStringsSep "." (lib.take 2 (builtins.splitVersion version))}" + libName="libsdrplay_api" + cp "${arch}/$libName.so.$majorMinorVersion" $out/lib/ + ln -s "$out/lib/$libName.so.$majorMinorVersion" "$out/lib/$libName.so.$majorVersion" + ln -s "$out/lib/$libName.so.$majorVersion" "$out/lib/$libName.so" + cp "${arch}/sdrplay_apiService" $out/bin/ + cp -r inc/* $out/include/ + cp 66-mirics.rules $out/lib/udev/rules.d/ + ''; + + meta = with lib; { + description = "SDRplay API"; + longDescription = '' + Proprietary library and api service for working with SDRplay devices. For documentation and licensing details see + https://www.sdrplay.com/docs/SDRplay_API_Specification_v${lib.concatStringsSep "." (lib.take 2 (builtins.splitVersion version))}.pdf + ''; + homepage = "https://www.sdrplay.com/downloads/"; + license = licenses.unfree; + maintainers = [ maintainers.pmenke ]; + platforms = platforms.linux; + }; +} diff --git a/pkgs/applications/radio/soapysdrplay/default.nix b/pkgs/applications/radio/soapysdrplay/default.nix new file mode 100644 index 000000000000..dbee593bd0d6 --- /dev/null +++ b/pkgs/applications/radio/soapysdrplay/default.nix @@ -0,0 +1,29 @@ +{ stdenv, lib, fetchFromGitHub, cmake, pkg-config, soapysdr, sdrplay }: + +stdenv.mkDerivation { + name = "soapysdr-sdrplay3"; + version = "20210425"; + + src = fetchFromGitHub { + owner = "pothosware"; + repo = "SoapySDRPlay3"; + rev = "e6fdb719b611b1dfb7f26c56a4df1e241bd10129"; + sha256 = "0rrylp3ikrva227hjy60v4n6d6yvdavjsad9kszw9s948mwiashi"; + }; + + nativeBuildInputs = [ cmake pkg-config ]; + + buildInputs = [ soapysdr sdrplay ]; + + cmakeFlags = [ + "-DSoapySDR_DIR=${soapysdr}/share/cmake/SoapySDR/" + ]; + + meta = with lib; { + description = "Soapy SDR module for SDRplay"; + homepage = "https://github.com/pothosware/SoapySDRPlay3"; + license = licenses.mit; + maintainers = [ maintainers.pmenke ]; + platforms = platforms.linux; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 470034df6d21..f2800b031f56 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -17833,6 +17833,8 @@ in sdnotify-wrapper = skawarePackages.sdnotify-wrapper; + sdrplay = callPackage ../applications/radio/sdrplay {}; + sblim-sfcc = callPackage ../development/libraries/sblim-sfcc {}; selinux-sandbox = callPackage ../os-specific/linux/selinux-sandbox { }; @@ -17938,6 +17940,8 @@ in soapyremote = callPackage ../applications/radio/soapyremote { }; + soapysdrplay = callPackage ../applications/radio/soapysdrplay { }; + soapysdr-with-plugins = callPackage ../applications/radio/soapysdr { extraPackages = [ limesuite