This commit is contained in:
Amy de Buitléir 2025-10-08 18:41:03 +01:00
parent 6c031b413a
commit 9554c9feb6
2 changed files with 16 additions and 3 deletions

View file

@ -6,9 +6,15 @@ access to the Linux `cowsay` command.
To accomplish this, we added a step to the `installPhase` that
modified that script by including the full path to `cowsay`.
== Using `writeShellApplication`
Let's see a different approach.
This time we won't start with an existing script;
we'll create it during installation.
The `writeShellApplication` will modify the script,
filling in the shebang and setting up the path with the dependencies specified in `runtimeInputs`.
For more information, see the
https://noogle.dev/f/pkgs/writeShellApplication[documentation].
////
$ mkdir tempwork
@ -32,6 +38,13 @@ Here's the flake in action.
$ nix run
....
== Other approaches
Nix provides a variety of functions that help with common tasks such as creating scripts.
See the section on https://nixos.org/manual/nixpkgs/stable/#chap-trivial-builders[trivial build helpers]
in the Nixpkgs reference manual, particularly
https://nixos.org/manual/nixpkgs/stable/#trivial-builder-writeShellScript[writeShellScript]
and https://nixos.org/manual/nixpkgs/stable/#trivial-builder-writeShellScriptBin[writeShellScriptBin].
////
Good adoc0 scripts clean up after themselves.
$ cd .. ; rm -rf tempwork # clean up

View file

@ -20,11 +20,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1759940130,
"narHash": "sha256-Mh7OwdNa3wtyEvPfKui/+Wu1wsjFaagcgk5b5cWAHQw=",
"lastModified": 1759944796,
"narHash": "sha256-MAfTOXtCiAbSbC3j8Mj1loQ312qtdhSXYpbauc01VTU=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "69cb92cdb8da8825ade450fe099028e3a3a278fd",
"rev": "11130c70a7d40569cbda12fa5d9dc09385b81538",
"type": "github"
},
"original": {