mirror of
https://codeberg.org/mhwombat/nix-book.git
synced 2026-01-11 00:02:37 +08:00
initial commit
This commit is contained in:
parent
5e2da971de
commit
9997760554
1 changed files with 39 additions and 0 deletions
39
source/recipes/shebang/main.adoc0
Normal file
39
source/recipes/shebang/main.adoc0
Normal file
|
|
@ -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
|
||||
....
|
||||
Loading…
Add table
Add a link
Reference in a new issue