What you’re looking for is called “language injection”.
For neovim you can install the nvim-treesitter plugin with the Nix parser (and more parsers for the language you wish to highlight). If you use the unstable channel nvim-treesitter should have some of these injections by default: for example it should highlight writeScript and buildPhase as bash, etc.
I’m currently using plugin = nvim-treesitter.withAllGrammars; # Syntax Highlighting in my config and I am also on unstable. Is there something else that I need to add? I also tried adding /* lua */ in front of my multiline strings but that didn’t work either.
It works without any configuration for me, and the syntax highlighting defaults to bash when the corresponding attribute name is somethingPhase or postSomething: