The default parsing method is to interpret the parsed data, in the same way that Nix would interpret it; each field in a derivation has a pre-defined meaning based on its position.
The above code will therefore produce output that looks something like this:
Sometimes, you'll only be interested in the AST, eg. because you're writing a pretty-printer. In that case, you'll want to use the `drv.ast` method instead.
Parses the specified `contents` and produces a descriptive object.
* __contents:__ The derivation contents to parse. This must be a string; if you're reading from a file in Node.js, you'll want to `.toString()` it first.
The descriptive object that's returned is structured as follows:
* __outputs:__*Array of objects.* An array of derivation outputs; these are the store objects that are built from the derivation. Each item in the array contains the following properties:
* __name:__*String.* The name of the derivation output.
* __path:__*String.* The store path of the derivation output.
* __expectedHashAlgorithm:__*String, may be empty.* The hashing algorithm used for the expected hash.
* __expectedHash:__*String, may be empty.* The hash that the output is expected to have; if not, it will be considered a build failure. The hash is stored as a hexadecimal string.
* __inputDerivations:__*Array of objects.* An array of input derivations; these are the derivations that are a dependency of this derivation. They must have completed building before this derivation can be built. Each item in the array contains the following properties:
* __path:__ The path of the input derivation, as a string. Note that this is a path to the __derivation__, and *not* to the derivation output!
* __wantedOutputs:__*Array of strings.* The names of the outputs of the input derivation that are required as a dependency of this derivation. These refer to the items in the `outputs` section of the input derivation.
* __inputSources:__*Array of strings.* An array of input sources; these are objects in the store that are copied from elsewhere, and that do not have their own derivation. Typical examples of this include builder scripts and source tarballs. Each item is a string containing the store path.
* __platform:__*String.* Describes the platform this derivation is meant to be built against. The platform strings used here are the same as those used throughout Nix and `nixpkgs`.
* __builder:__*String.* The builder to use for building ("realizing") this derivation.
* __builderArguments:__*Array of strings.* The arguments to pass to the builder.
* __environmentVariables__*Array of objects.* An array of environment variables in key/value format. These are the environment variables that are set when the builder is executed. Each item in the array contains the following properties:
* __name:__*String.* The name of the environment variable.
* __value:__*String, may be empty.* The value of the environment variable. It may contain variable interpolations.
### drv.ast(contents)
Parses the specified `contents` and produces an AST (Abstract Syntax Tree).
* __contents:__ The derivation contents to parse. This must be a string; if you're reading from a file in Node.js, you'll want to `.toString()` it first.
Each AST node has the following properties:
* __type:__*String.* The type of node. Possible options are:
* __"deriveTag":__ The root `Derive` tag (eg. `Derive(contents)`).
* __"array":__ An array (eg. `[contents]`).
* __"tuple":__ A tuple (eg. `(contents)`).
* __items:__*Array.* An array of items contained within this node. Each item is either an AST node or a string literal.
The root of the AST is always a `deriveTag`. String literals in the derivation are represented as string literals in the AST as well; all other syntactic constructs are represented as AST nodes.