diff --git a/source/recipes/shebang/main.adoc0 b/source/recipes/shebang/main.adoc0 new file mode 100644 index 0000000..3c2157b --- /dev/null +++ b/source/recipes/shebang/main.adoc0 @@ -0,0 +1,39 @@ += Scripts with access to... + +You can use `nix shell` to run scripts in arbitrary languages, providing +the necessary dependencies. +This is particularly convenient for standalone scripts +because you don't need to create a repo and write a separate `flake.nix`. +The script should start with two _"shebang"_ (`#!`) commands. +The first should invoke `nix`. +The second should declares the script interpreter and any dependencies. + + +== A top level package from the Nixpkgs/NixOS repo + +[source,bash,linenums,highlight=1..2] +.Script +.... +$# cat run-nixpkg.sh +.... + +.Output +.... +$# ./run-nixpkg.sh +.... + +== A flake + +In this example, we will use a flake defined in a remote git repo. +However, you can use any of the flake reference styles defined in <<#flakeref>>. + +[source,bash,linenums,highlight=1..2] +.Script +.... +$# cat run-flake.sh +.... + +.Output +.... +$# ./run-flake.sh +....