initial commit

This commit is contained in:
Amy de Buitléir 2023-11-28 16:11:37 +00:00
parent 0311f3a7e5
commit 7761303cd4
9 changed files with 111 additions and 0 deletions

View file

@ -0,0 +1,5 @@
= Set an environment variable
Ex: Set the value of the environment variable FOO to "`bar`"
include::shell/main-generated.adoc[leveloffset=+1]

View file

@ -0,0 +1,8 @@
= Access to a Haskell package on your local computer, with interdependencies
Ex: Access four Haskell packages
(`pandoc-linear-table`, `pandoc-logic-proof`, `pandoc-columns` and `pandoc-maths-web`)
that are on my hard drive.
The fourth package depends on the first three to build.
include::shell/main-generated.adoc[leveloffset=+1]

View file

@ -0,0 +1,7 @@
= Access to a Haskell package on your local computer
Ex: Access three Haskell packages
(`pandoc-linear-table`, `pandoc-logic-proof`, and `pandoc-columns`)
that are on my hard drive.
include::shell/main-generated.adoc[leveloffset=+1]

View file

@ -0,0 +1,13 @@
= In a Haskell script
[source,haskell,linenums]
.Script
....
include::my-script.sh[]
....
.Output
....
$# ./my-script.sh
....

41
source/recipes/main.adoc Normal file
View file

@ -0,0 +1,41 @@
= Recipes
This chapter provides examples of how to use Nix in a variety of scanarios.
Multiple types of recipes are provided are provided for some scenarios;
comparing the different recipes will help you better understand Nix.
- An _"ad hoc" shell_
is useful when you want to quickly create an environment
for a one-off task.
- A _traditional nix shell_
is useful when you want to define an environment that you will
use more than once.
- _Nix flakes_
are the recommended approach for development projects.
- You can use `nix-shell` to run scripts in arbitrary languages, providing
the necessary dependencies. This is particularly convenient for
standalone scripts because you dont 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 script
interpreter and any dependencies.
include::nixpkgs-pkg/main.adoc[leveloffset=+1]
include::remote-git/main.adoc[leveloffset=+1]
include::remote-git-flake/main.adoc[leveloffset=+1]
include::haskell-nixpkg/main.adoc[leveloffset=+1]
include::haskell-local/main.adoc[leveloffset=+1]
include::haskell-local-deps/main.adoc[leveloffset=+1]
include::python-nixpkg/main.adoc[leveloffset=+1]
include::env-var/main.adoc[leveloffset=+1]

View file

@ -0,0 +1,10 @@
= Access to a top-level package from the Nixpkgs/NixOS repo
Ex: Access two packages from nixpkgs:
hello and cowsay.
include::cli/main-generated.adoc[leveloffset=+1]
include::shell/main-generated.adoc[leveloffset=+1]
include::shebang/main-generated.adoc[leveloffset=+1]

View file

@ -0,0 +1,11 @@
= Access to a Python library package in the nixpkgs repo (without using a Python builder)
Occasionally you might want to run a short Python program that depends on a Python library,
but you don't want to bother configuring a builder.
Example: Access the `html_sanitizer` package from the `python3nnPackages` set in the nixpkgs repo.
// TODO include::shell/main-generated.adoc[leveloffset=+1]
include::shebang/main-generated.adoc[leveloffset=+1]

View file

@ -0,0 +1,8 @@
= Access to a flake defined in a remote git repo
Ex: Access a flake called `hello-flake`,
which is defined in a remote git repo on codeberg.
To use a package from GitHub, GitLab, or any other public platform,
modify the URL.
include::shell/main-generated.adoc[leveloffset=+1]

View file

@ -0,0 +1,8 @@
= Access to a package defined in a remote git repo
Ex: Access a package called `hello-nix`,
which is defined in a remote git repo on codeberg.
To use a package from GitHub, GitLab, or any other public platform,
modify the URL.
include::shell/main-generated.adoc[leveloffset=+1]