···4950## `writeShellApplication` {#trivial-builder-writeShellApplication}
5152-This can be used to easily produce a shell script that has some dependencies (`buildInputs`). 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).
5354For example, look at the following code:
55···57writeShellApplication {
58 name = "show-nixos-org";
5960- buildInputs = [ curl w3m ];
6162 text = ''
63 curl -s 'https://nixos.org' | w3m -dump -T text/html
···4950## `writeShellApplication` {#trivial-builder-writeShellApplication}
5152+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).
5354For example, look at the following code:
55···57writeShellApplication {
58 name = "show-nixos-org";
5960+ runtimeInputs = [ curl w3m ];
6162 text = ''
63 curl -s 'https://nixos.org' | w3m -dump -T text/html
+3-3
pkgs/build-support/trivial-builders.nix
···260 * # Writes my-file to /nix/store/<store path>/bin/my-file and makes executable.
261 * writeShellApplication {
262 * name = "my-file";
263- * buildInputs = [ curl w3m ];
264 * text = ''
265 * curl -s 'https://nixos.org' | w3m -dump -T text/html
266 * '';
···269 writeShellApplication =
270 { name
271 , text
272- , buildInputs ? [ ]
273 , checkPhase ? null
274 }:
275 writeTextFile {
···282 set -o nounset
283 set- o pipefail
284285- export PATH="${makeBinPath buildInputs}:$PATH"
286287 ${text}
288 '';
···260 * # Writes my-file to /nix/store/<store path>/bin/my-file and makes executable.
261 * writeShellApplication {
262 * name = "my-file";
263+ * runtimeInputs = [ curl w3m ];
264 * text = ''
265 * curl -s 'https://nixos.org' | w3m -dump -T text/html
266 * '';
···269 writeShellApplication =
270 { name
271 , text
272+ , runtimeInputs ? [ ]
273 , checkPhase ? null
274 }:
275 writeTextFile {
···282 set -o nounset
283 set- o pipefail
284285+ export PATH="${makeBinPath runtimeInputs}:$PATH"
286287 ${text}
288 '';