mirror of
https://codeberg.org/mhwombat/nix-book.git
synced 2026-02-03 19:48:27 +08:00
initial commit
This commit is contained in:
parent
1935bcebb2
commit
fb453b751f
5 changed files with 600 additions and 0 deletions
40
source/shebangs/_include.adoc0
Normal file
40
source/shebangs/_include.adoc0
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
== Nix-shell shebangs
|
||||
|
||||
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-shell`. The second should declares the scrpt
|
||||
interpreter and any dependencies. Here are some examples.
|
||||
|
||||
=== A Bash script depending on a package in the nixpkgs repo.
|
||||
|
||||
Script:
|
||||
|
||||
[source,bash,linenums]
|
||||
....
|
||||
include::bash-with-nixpkg.sh[]
|
||||
....
|
||||
|
||||
Output:
|
||||
|
||||
....
|
||||
$# shebangs/bash-with-nixpkg.sh
|
||||
....
|
||||
|
||||
=== A Python script depending on a package in the nixpkgs repo.
|
||||
|
||||
Script:
|
||||
|
||||
[source,bash,linenums]
|
||||
....
|
||||
include::python-with-nixpkg.sh[]
|
||||
....
|
||||
|
||||
Output:
|
||||
|
||||
....
|
||||
$# shebangs/python-with-nixpkg.sh
|
||||
....
|
||||
Loading…
Add table
Add a link
Reference in a new issue