Trivial builders
There are a couple of functions provide in Nixpkgs that help with
building derivations. The most important one,
stdenv.mkDerivation, has already been
documented above. These wrap
stdenv.mkDerivation, making it easier to use
in certain cases.
runCommand
This takes three arguments, name,
env, and buildCommand.
name is just the name that Nix will use to
refer to the derivation. env is an attribute
set specifying environment variables that will be set for this
derivation. buildCommand specifies the
commands that will be run to create this derivation. Note that
you will need to create $out for Nix to
register the command as successful.
runCommandCC
This works just like runCommand. The only
difference is that it also provides a C compiler for your use.
To minimize your dependencies, you should only use this if you
are sure you will need a C compiler as part of running your command.
writeTextFile
This writes text to the Nix store. This is
useful for creating scripts from Nix expressions. This takes an
attribute set and expects two arguments,
name and text.
name corresponds to the name used in the Nix
store path. text will be the contents of the
file. You can also set executable to true to
make this file have the executable bit set.
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 directory.