Shell Scripts: Difference between revisions
imported>Milahu + demo for writeShellScript |
imported>Milahu + section Posix Shell |
||
Line 16: | Line 16: | ||
}; | }; | ||
</syntaxHighlight> | </syntaxHighlight> | ||
== Posix Shell == | |||
some environments (like OpenWRT, via <code>busybox</code>) offer only a "limited" shell (<code>sh</code> instead of <code>bash</code>). | |||
on nixos, posix shells are provided by the packages <code>dash</code> and <code>posh</code> |
Revision as of 09:15, 1 October 2021
the package writeShellScript
can be used to add shell scripts to nix expressions
someBuildHelper = { name, sha256 }:
stdenv.mkDerivation {
inherit name;
outputHashMode = "recursive";
outputHashAlgo = "sha256";
outputHash = sha256;
builder = writeShellScript "builder.sh" ''
echo "hi, my name is ''${0}" # escape bash variable
echo "hi, my hash is ${sha256}" # use nix variable
echo "hello world" >output.txt
'';
};
Posix Shell
some environments (like OpenWRT, via busybox
) offer only a "limited" shell (sh
instead of bash
).
on nixos, posix shells are provided by the packages dash
and posh