NixOS/nix — pull request #52 by shlevy (2012-09-16 18:55:55+00:00)
Title: File substitutes

This branch (which includes my structured-context work and the better errors when importing from derivations work) adds some new substituter operations (--query haveFile, --query fileInfo, and --read) that should provide enough information to determine if a substitute is available for a derivation that requires importing from another derivation to be realised. Essentially, a substituter can serve up information about some files (type, length, recursive hash, etc., used by coerceToString with copyToStore=true) and the full contents of some regular files (used by prim_import), allowing the import from derivation to be done without the full derivation being realised.

This does not update any real substituters to support these new operations, though tests/file-substituter.sh shows the interface they must follow.

A sketch of how this might be used: I import build.nix from nix's tarball, and the substituter gives back the full nix expression which gets parsed and evaled. build.nix builds individual .c files, so the substituter tells me the recursive hash of those files (but it doesn't need the full contents) so nix can determine the hash of compileC derivations.

There are other operations (e.g. readFile) which might want to use this file substituter mechanism in the import-from-derivation case, but import and coerceToString seemed the most important.