One issue I've had with personal shell scripts is that the dependencies are often implicit, or command line arguments change, leading to (sometimes silent and critical) behavior. With Nix you can write shell scripts with a nix-shell shebang[0], specify the dependencies and the rest of the script will run with the dependencies satisfied, for instance, this will execute GNU Hello regardless of whether it is already in the path or not<p><pre><code> #! /usr/bin/env nix-shell
#! nix-shell --pure -i bash -p "hello"
hello
</code></pre>
a more realistic example is[1] which generates[2], and if necessary, the Nixpkgs revision can be pinned to fix the dependencies in time. This approach also extends across languages and some of my scripts are written in Haskell which is interpreted!<p>The upshot of all this is that you can write reproducible shell scripts as if you had every package in Nixpkgs available to you, and share it easily with others.<p>[0] <a href="https://nix.dev/tutorials/ad-hoc-developer-environments.html#reproducible-executables" rel="nofollow">https://nix.dev/tutorials/ad-hoc-developer-environments.html...</a><p>[1] <a href="https://edef.eu/~qyliss/nix/lib/gen.sh" rel="nofollow">https://edef.eu/~qyliss/nix/lib/gen.sh</a><p>[2] <a href="https://edef.eu/~qyliss/nix/lib/" rel="nofollow">https://edef.eu/~qyliss/nix/lib/</a>