Can overlay override the setting of some package globally?

As an example (and that’s what I actually want):

Many packages rely on the package uhd. Can I create a new version of uhd with some settings modified and all other packages that relies on it will automatically point to the new uhd that I created?

Thanks!

Let me answer this question myself.

The solution is simple: use overlay and simple set the new package name to the old one.

In my case, simply let

final: prev: {
  uhd = (prev.uhd.overrideAttrs(oldAttrs: rec {

#just ignore the following codes
  removeInstalledTests = ''
  echo "skip remove installed tests"
  '';
  postPhases = [ "installFirmware" "removeInstalledTests" "replaceB210Fw" ];

  b210Fw=/etc/nixos/pkgs/uhd/usrp_b210_fpga.bin;
  replaceB210Fw=''
  cp -fv $b210Fw "$out/share/uhd/images/usrp_b210_fpga.bin"
  '';
  })).override {enableUtils=true; enableExamples=true;};
}
1 Like