I have found a working example using nix-shell shebangs for multiple programming languages:
#! /usr/bin/env nix-shell #! nix-shell -I nixpkgs=http://nixos.org/channels/nixpkgs-unstable/nixexprs.tar.xz echo "hello from bash"; #! nix-shell -p python -i python python <<END_OF_PYTHON import sys print ("hello from python") sys.exit(0) END_OF_PYTHON #! nix-shell -i ruby -p ruby ruby <<END_OF_RUBY puts "hello from ruby" exit END_OF_RUBY #! nix-shell -i bash echo "goodbye from bash!";
Just a template but you get the general idea.
Basically using here docs to breakout of language one and also re/using the according shebang (i. e. see near bottom in the example code) to switch or return to language (one)
EDIT: Deleted that part as I am unsure about this and also unnecessary information.
I guess with languages not using
# as comment marker you’d have to comment out certain sections in this example (shebang lines or continuations again should suffice) according to their comment token scheme (i. e. erlang smth like
-define(HIDE_SHEBANG, <<" ...">>). )