Am I doing the overlay properly?

I’m trying to get SoapySDR working with the SoapySDRPlay libraries working with NixOS on my machine. It looks like it should be straightforward.

It looks like adding the option:
services.sdrplayApi.enable = true then from the docs for that option adding the overlay:
soapysdr-with-plugins = super.soapysdr.override { extraPackages = [ super.soapysdrplay ]; };

I think I did this properly in my config:
From my config: nixos-config/configuration.nix at bfdf904431518018e22f95740aa22bb96abc1708 · jevy/nixos-config · GitHub

The key reason for doing this is making the that the package knows the correct path for the libraries but it doesn’t seem like the way to set this (SOAPY_SDR_PLUGIN_PATH) is set properly:

If I run SoapySDRUtils --info
It points to: /nix/store/wxawrabx434gi8phbpimx656417a68i2-soapysdr-0.8.1/lib
which contains libSoapySDR.so libSoapySDR.so.0.8 libSoapySDR.so.0.8.1 (but no reference to SDRPlay.

But it seems like it should point to:
/run/current-system/sw/lib/SoapySDR/modules0.8 since it contains libsdrPlaySupport.so

I’ve been trying to debug this but I haven’t been able to nail it dwon.

I think what currently missing is giving it the same name in nixpkgs such that the overridden version being overlaid is what other modules and parts of nixpkgs are referring to:

  services.sdrplayApi.enable = true;
  nixpkgs.overlays = [
    (
      self: super:
      {
        soapysdr = super.soapysdr.override { extraPackages = [ super.soapysdrplay ]; };
      }
    )
  ];

This way anything that currently references pkgs.soapysdr will refer to version created by the overlay. This also assumes the override portion itself it correct, but I’m not familiar with that particular package.

Thanks for reaching out @wkral! I tried the change you suggested but I got an error: infinite recursion encountered

Reference of change: NOT WORKING Infinite recursion · jevy/nixos-config@b0d1f54 · GitHub

Could you post the error with more detail if possible? Is this an isolated change or could this be exposing something else going on?

Perhaps there is also something in super.soapysdrpay referring to super.soapysdr or vice versa.

Sure thing!
There is no reference to soapysdr in the option nixpkgs/sdrplay.nix at 8a053bc2255659c5ca52706b9e12e76a8f50dbdd · NixOS/nixpkgs · GitHub
The soapysdr pkg: nixpkgs/default.nix at 8a053bc2255659c5ca52706b9e12e76a8f50dbdd · NixOS/nixpkgs · GitHub

The output

~ ❯ sudo nixos-rebuild switch --show-trace                                                                                                                                             34s
building Nix...
building the system configuration...
error: while evaluating the attribute 'activationScript' of the derivation 'nixos-system-nixos-21.11.334934.8a053bc2255' at /nix/store/1wyhmdzb1pbwzz0ks6482rld30cl2amf-nixos-21.11.334934.8a053bc2255/nixos/pkgs/stdenv/generic/make-derivation.nix:205:7:
while evaluating the attribute 'system.activationScripts.script' at /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/activation/activation-script.nix:136:9:
while evaluating 'systemActivationScript' at /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/activation/activation-script.nix:20:33, called from /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/activation/activation-script.nix:136:18:
while evaluating 'textClosureMap' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/strings-with-deps.nix:75:35, called from /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/activation/activation-script.nix:49:9:
while evaluating 'id' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/trivial.nix:14:5, called from undefined position:
while evaluating the attribute 'text' at /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/activation/activation-script.nix:9:5:
while evaluating the attribute 'text' at undefined position:
while evaluating 'g' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:301:19, called from undefined position:
while evaluating anonymous function at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:171:72, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:304:20:
while evaluating the attribute 'value' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:585:9:
while evaluating the option `system.activationScripts.etc.text':
while evaluating the attribute 'mergedValue' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:617:5:
while evaluating the attribute 'values' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:611:9:
while evaluating the attribute 'values' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:710:7:
while evaluating anonymous function at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:597:28, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:597:17:
while evaluating definitions from `/nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/etc/etc.nix':
while evaluating 'dischargeProperties' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:669:25, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:598:137:
while evaluating the attribute 'value' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:452:44:
while evaluating the attribute 'buildCommand' of the derivation 'etc' at /nix/store/1wyhmdzb1pbwzz0ks6482rld30cl2amf-nixos-21.11.334934.8a053bc2255/nixos/pkgs/stdenv/generic/make-derivation.nix:205:7:
while evaluating 'concatMapStringsSep' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/strings.nix:110:5, called from /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/etc/etc.nix:54:7:
while evaluating anonymous function at /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/etc/etc.nix:54:33, called from undefined position:
while evaluating 'concatMapStringsSep' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/strings.nix:110:5, called from /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/etc/etc.nix:54:43:
while evaluating 'escapeShellArg' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/strings.nix:318:20, called from undefined position:
while evaluating the attribute 'source' at undefined position:
while evaluating 'g' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:301:19, called from undefined position:
while evaluating anonymous function at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:171:72, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:304:20:
while evaluating the attribute 'value' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:585:9:
while evaluating the option `environment.etc.dbus-1.source':
while evaluating the attribute 'mergedValue' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:617:5:
while evaluating anonymous function at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:619:17, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:619:12:
while evaluating 'check' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/types.nix:362:15, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:619:22:
while evaluating the attribute 'serviceDirectories' of the derivation 'dbus-1' at /nix/store/1wyhmdzb1pbwzz0ks6482rld30cl2amf-nixos-21.11.334934.8a053bc2255/nixos/pkgs/stdenv/generic/make-derivation.nix:205:7:
while evaluating anonymous function at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/types.nix:371:14, called from undefined position:
while evaluating the attribute 'value' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:630:27:
while evaluating anonymous function at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:619:17, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:619:12:
while evaluating 'check' at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/types.nix:362:15, called from /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:619:22:
while evaluating the attribute 'passAsFile' of the derivation 'system-path' at /nix/store/1wyhmdzb1pbwzz0ks6482rld30cl2amf-nixos-21.11.334934.8a053bc2255/nixos/pkgs/stdenv/generic/make-derivation.nix:205:7:
while evaluating the attribute 'passAsFile' at /nix/store/1wyhmdzb1pbwzz0ks6482rld30cl2amf-nixos-21.11.334934.8a053bc2255/nixos/pkgs/build-support/buildenv/default.nix:77:5:
while evaluating the attribute 'buildInputs' of the derivation 'cubicsdr-0.2.5' at /nix/store/1wyhmdzb1pbwzz0ks6482rld30cl2amf-nixos-21.11.334934.8a053bc2255/nixos/pkgs/stdenv/generic/make-derivation.nix:205:7:
while evaluating the attribute 'postFixup' of the derivation 'soapysdr-0.8.1' at /nix/store/1wyhmdzb1pbwzz0ks6482rld30cl2amf-nixos-21.11.334934.8a053bc2255/nixos/pkgs/stdenv/generic/make-derivation.nix:205:7:
while evaluating 'optionalString' at /nix/store/1wyhmdzb1pbwzz0ks6482rld30cl2amf-nixos-21.11.334934.8a053bc2255/nixos/lib/strings.nix:202:5, called from /nix/store/1wyhmdzb1pbwzz0ks6482rld30cl2amf-nixos-21.11.334934.8a053bc2255/nixos/pkgs/applications/radio/soapysdr/default.nix:37:15:
while evaluating the attribute 'buildInputs' of the derivation 'limesuite-20.10.0' at /nix/store/1wyhmdzb1pbwzz0ks6482rld30cl2amf-nixos-21.11.334934.8a053bc2255/nixos/pkgs/stdenv/generic/make-derivation.nix:205:7:
while evaluating the attribute 'postFixup' of the derivation 'soapysdr-0.8.1' at /nix/store/1wyhmdzb1pbwzz0ks6482rld30cl2amf-nixos-21.11.334934.8a053bc2255/nixos/pkgs/stdenv/generic/make-derivation.nix:205:7:
while evaluating 'optionalString' at /nix/store/1wyhmdzb1pbwzz0ks6482rld30cl2amf-nixos-21.11.334934.8a053bc2255/nixos/lib/strings.nix:202:5, called from /nix/store/1wyhmdzb1pbwzz0ks6482rld30cl2amf-nixos-21.11.334934.8a053bc2255/nixos/pkgs/applications/radio/soapysdr/default.nix:37:15:
while evaluating the attribute 'buildInputs' of the derivation 'soapysdr-sdrplay3' at /nix/store/1wyhmdzb1pbwzz0ks6482rld30cl2amf-nixos-21.11.334934.8a053bc2255/nixos/pkgs/stdenv/generic/make-derivation.nix:205:7:
infinite recursion encountered, at undefined position

Sure enough, soapysdrpaly does refer to soapysdr and the overlay provided does create that recurrsion.

This is a bit of a guess on my part, but I think there is a chance that if you were to use, self.soapysdrplay in the override, then it might break the recursion. That might even be one of the indended reasons for having the two arguments, but I can’t find specific documentation to that effect.

I know that self or the first argument referrs to the version of nixpkgs after the overlay is applied so I think that should make the refences different, so there shouldn’t be a reference lookup loop. Probably worth giving it a shot, but I’m speculating here.

1 Like

Well what do you know. Changing the references from super to self worked! Amazing! I think that makes sense then, if it was super, it would look backwards, trying to find the “root derivation” (is that the right idea). If it’s self, there is no lookup.

Thanks a lot for your help! That change took 4 hours to dig into plus your help :smiley:

2 Likes