diff options
author | github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | 2021-11-10 00:01:31 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-10 00:01:31 +0000 |
commit | 6e4d2d1f105c0092031c9aa490f14f6ade51e74b (patch) | |
tree | c48d94c40ccd4c4efacd545edc11a48e00937be2 /doc | |
parent | 576f01a21f6f2169b1f2629d515797d4e23b89dc (diff) | |
parent | 4d765caecdc91e6efa61822499f2275b59926dee (diff) | |
download | nixpkgs-6e4d2d1f105c0092031c9aa490f14f6ade51e74b.tar nixpkgs-6e4d2d1f105c0092031c9aa490f14f6ade51e74b.tar.gz nixpkgs-6e4d2d1f105c0092031c9aa490f14f6ade51e74b.tar.bz2 nixpkgs-6e4d2d1f105c0092031c9aa490f14f6ade51e74b.tar.lz nixpkgs-6e4d2d1f105c0092031c9aa490f14f6ade51e74b.tar.xz nixpkgs-6e4d2d1f105c0092031c9aa490f14f6ade51e74b.tar.zst nixpkgs-6e4d2d1f105c0092031c9aa490f14f6ade51e74b.zip |
Merge master into staging-next
Diffstat (limited to 'doc')
-rw-r--r-- | doc/builders/trivial-builders.chapter.md | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/doc/builders/trivial-builders.chapter.md b/doc/builders/trivial-builders.chapter.md index 46620e1b459..c3a3572cd9f 100644 --- a/doc/builders/trivial-builders.chapter.md +++ b/doc/builders/trivial-builders.chapter.md @@ -47,6 +47,28 @@ These functions write `text` to the Nix store. This is useful for creating scrip Many more commands wrap `writeTextFile` including `writeText`, `writeTextDir`, `writeScript`, and `writeScriptBin`. These are convenience functions over `writeTextFile`. +## `writeShellApplication` {#trivial-builder-writeShellApplication} + +This can be used to easily produce a shell script that has some dependencies (`runtimeInputs`). It automatically sets the `PATH` of the script to contain all of the listed inputs, sets some sanity shellopts (`errexit`, `nounset`, `pipefail`), and checks the resulting script with [`shellcheck`](https://github.com/koalaman/shellcheck). + +For example, look at the following code: + +```nix +writeShellApplication { + name = "show-nixos-org"; + + runtimeInputs = [ curl w3m ]; + + text = '' + curl -s 'https://nixos.org' | w3m -dump -T text/html + ''; +} +``` + +Unlike with normal `writeShellScriptBin`, there is no need to manually write out `${curl}/bin/curl`, setting the PATH +was handled by `writeShellApplication`. Moreover, the script is being checked with `shellcheck` for more strict +validation. + ## `symlinkJoin` {#trivial-builder-symlinkJoin} This can be used to put many derivations into the same directory structure. It works by creating a new derivation and adding symlinks to each of the paths listed. It expects two arguments, `name`, and `paths`. `name` is the name used in the Nix store path for the created derivation. `paths` is a list of paths that will be symlinked. These paths can be to Nix store derivations or any other subdirectory contained within. |