Using a firewall on-demand (not declaratively)?

Good morning,

So far, I have been using the firewall declaratively in this way:

networking.firewall.allowedTCPPorts = [ (...) ];
networking.firewall.allowedUDPPorts = [ (...) ];
networking.firewall.allowedTCPPortRanges = [   {   (...)  }  ];
networking.firewall.allowedUDPPortRanges = [ { 
   from = (...) ; 
   to = (...) ; 
} ];

This method works, but now I would like to use it imperatively (on-demand, per request), e.g., in a bash script.

Can I use the ufw command for this? Won’t it cause any issues with the NixOS configuration?

I’m asking to avoid unnecessary problems.

thanks

UPDATE:
i found package: nixos-firewall-tool

… which seems exactly what i am looking for. Going to test it…