diff --git a/source/recipes/build/nixpkg/main.adoc0 b/source/recipes/build/nixpkg/main.adoc0 index 19dc708..f529e08 100644 --- a/source/recipes/build/nixpkg/main.adoc0 +++ b/source/recipes/build/nixpkg/main.adoc0 @@ -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 diff --git a/source/recipes/build/nixpkg/tempwork/flake.lock b/source/recipes/build/nixpkg/tempwork/flake.lock index f3a57cc..aecd697 100644 --- a/source/recipes/build/nixpkg/tempwork/flake.lock +++ b/source/recipes/build/nixpkg/tempwork/flake.lock @@ -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": {