You can always refer to the tarball of the branch name on GitHub. See the example in the shell.nix tutorial. It’s also possible to specify a certain commit to ensure exact reproducibility (as far as technically possible).
It’s more convenient to manage dependencies on remote file system trees — such as adding source specifications, updating versions, and doing that programmatically e.g. in CI — with dedicated tooling. For example, see the introduction to npins.