How to use nix-shell with groovy

This looks like a groovy issue. I’m not particularly familiar with groovy, but my guess is that # is not a comment character, and that groovy as a special case allows the first line to begin with #! but disallows this otherwise.

In this scenario, my recommendation is to instead split it into two files like so:

> cat update-nix-dependencies
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p bash groovy
exec groovy update-nix-dependencies.groovy "$@"
> cat update-nix-dependencies.groovy
println "hello"