Scripts to (interactively) demonstrate capabilities of Nix.
Nix with flakes enabled must be available.
Run all demos in order using
$ ./demo-full.sh
or run one particular demo using
./<xx-demo-name>/demo.sh
⚠ The program will pause before and after commands are executed to allow some time to absorb what is happening. [▼]
will be displayed: press any* key to continue.
⚠ If you press 's' when waiting at a pause after a command is printed but before it is executed, it will be skipped instead.
⚠ The demos build a number of obscure variants of packages that are not provided by https://cache.nixos.org/, so this might take a long time the first time you run them. Once the packages are present in the Nix store the scripts run in seconds (in automatic mode).
⚠ The container-related demos use rootless Podman, which needs some configuration files.
If they don't exist yet they will be created in ~/.config/containers/
and will not removed. The scripts do make a best-effort attempt at removing any containers that are created.
Rootless Podman has some special requirements; most of them are provided by Nix, but e.g. /etc/subuid
and /etc/subgid
configuration must be fixed by an administrator.
The various demos will show you how to:
Available options:
$ ./demo-full.sh -h
./demo-full.sh: run all 'demo.sh' scripts in order
-h|--help|-?: Show usage
-a|--auto: run in automatic mode (no pausing)
-g|--gcroots <create|delete|recreate|print>: (re)create, delete, or print Nix garbage collector roots for nix build/run/develop outputs
-l|--lint: run linter on shell files
⚠ The garbage collector roots are of the form /nix/var/nix/gcroots/per-user/${USER}/nix-container-demo-*
, you may want to clean them if this demo changes.
Available environment variables:
LIBDEMO_USE_COLOUR
: enable (1, default) or disable (0) the use of colour in libdemo. Colours may still appear in output from other packages.LIBDEMO_USE_UNICODE
: enable (1, default) or disable (0) the use of unicode in libdemo. Unicode may still appear in output from other packages.LIBDEMO_INTERACTIVE
: enable (1, default) or disable (0) interactive mode. In non-interactive (automatic) mode, pauses and i
commands are skipped.WRAP_NIX_MAKE_GCROOTS
: enable (1) or disable (0, default) creation of Nix garbage collector roots for nix build/run/develop outputs.An attempt at making live, but prepared, presentations in bash.
Demo files demo.sh
are bash files that source libdemo/libdemo.sh
, providing some convenience functions and abbreviated forms for them:
h
: Print arguments as a header.n
: Print arguments as a note.,
: Print arguments as regular text.x
: Print the provided arguments and execute them, expecting success in automatic mode and ignoring exit status in interactive mode.
Pauses after the command is shown and after the command is run.f
: Print the provided arguments and execute them, expecting failure in automatic mode and ignoring exit status in interactive mode.
Pauses after the command is shown and after the command is run.i
: Print the provided arguments and execute them in interactive mode only, ignoring exit status.
Pauses after the command is shown and after the command is run.p
: Pause until any key is pressed.c
: Clear terminal.Because of how the command evaluation is structured, care must be taken with characters that bash might interpret, escaping them where necessary.
libdemo
and the demonstrations are provided under the MIT license.src/simple.c
is a slightly modified copy of https://curl.se/libcurl/c/simple.html and subject to its own license.data/weather-static
was generated from curl wttr.in/Delft
.