What is the easiest way to replace binary `zathura` with `zathura-sandbox` systemwide in NixOS?

Recently just notice there is a zathura-sandbox binary in the zathura package, which basically suit all of my use case. However I am still finding a way to replace all the zathura to zathura-sandbox, including some of my shell scripts. If there is a way to do that in nix I think I don’t have to touch all of the scripts because I am afraid I may not change all of it.

1 Like

i guess you could overlay it to set its meta.mainProgram to the other binary

2 Likes

thanks! Didn’t know the meta attribute set also can be overlayed. Will try it later

1 Like

I use this finally

final: prev: {
  zathura = prev.zathura.overrideAttrs (
    finalAttls: prevAttrs: {
      # symlinkJoin underlying use buildCommand under postBuild
      buildCommand = prevAttrs.buildCommand + ''
        mv $out/bin/zathura $out/bin/zathura-no-sandbox
        mv $out/bin/zathura-sandbox $out/bin/zathura
      '';
    }
  );
}