A Nixᛦ expression which describes a build action is called a derivation. The result (since a derivation is a function) of a derivation is an object in the Nix storeᛦ.
fetchTarball downloads the given URL, unpacks it, and returns the Nix storeᛦ path containing the unpacked tree. The file must be a tarballᛦ, ideally one with a single directory at the top level.
toFile name s
The derivations generated by fetchurl and related Nix functions are fixed-output derivations. This allows for source tarballs and similar files to be downloaded to the Nix storeᛦ without breaking every dependent when a source mirror or other metadata gets updated.
path takes a set of attributes describing an enriched version of the built in path type. The path attribute is required. The name attribute determines the Nix storeᛦ name. The filter attribute takes a filter like that in filterSourceᛦ. recursive will store a flat hash if false or a NAR archive hash if set to true (the default). See fixed-output derivationsᛦ for more information. The sha256 argument is the expected sha256 hash of the file at path.
We use filterSource e1 e2 to selectively copy files to the Nix storeᛦ when copying a source. e1 is a predicate function in two arguments, the full path to the file and the type of the file. Each file or directory in e2 which returns true under e1 will be copied to the store and all others will be ignored.
filterSource e1 e2
Fetches a path into the Nix storeᛦ from Gitᛦ. fetchGit can take either a URL, which fetches the HEAD of the repo. Otherwise, a set with attributes url, name (defaults to URL basenameᛦ), rev (defaults to tip of ref), and ref (any Git ref like a branch or a tag).
Every attribute of the derivation is available to the builder script as an environment variable. $perl and $src point to the Nix storeᛦ path for the perl argument and the location to which the sources were saved. Everything is in the store!