Is it possible to write custom rules to the NixOS firewall?

It seems a bit hacky. From what I gather[1][2] networking.firewall.extraCommands will keep adding the rules on every “deployment”. Does that mean every time I run nixos-rebuild switch? If so is there a better way to do it?

[1]

[2]