Install doas using Ubuntu's package manager:
sudo apt install doas
That will install doas with SUID, so maybes that's all you need, but it depends on the behavior of your unnamed Nix package that uses doas. If that package just looks for doas on the PATH environment variable it got when it was launched, you should be fine. However, lots of Nix packages have wrapper scripts that overwrite the PATH, in order to make the system more pure and reliable. If your Nix package is using the wrong doas, you will want to somehow override or reconfigure the definition of your Nix package (perhaps using an overlay) so that instead of using pkgs.doas, it uses the following little Nix package I wrote called doas-link, which just creates a symbolic link to the one installed by Ubuntu:
pkgs.stdenv.mkDerivation {
name = "doas-link";
phases = [ "installPhase" ];
installPhase = ''
mkdir -p $out/bin
ln -s /usr/bin/doas $out/bin/
'';
}
If you tell me more details about what package you're using and how you are building it, then I might be able to help further.