Import From Derivation: Difference between revisions

imported>Roberth
No edit summary
imported>Roberth
m Use (f drv) to clarify that it's only such usages that cause IFD
Line 77: Line 77:
<h2>Recognizing IFD</h2>
<h2>Recognizing IFD</h2>


The textbook case of IFD looks like `import e` where `e` is an expression that requires a build to provide the value. However, `import` is not the only function that can require a build. For example, `builtins.readFile` can have the same effect.
The textbook case of IFD looks like `import (f drv)` where `f drv` is an expression that requires a build in order to return a value. However, `import` is not the only function that can require a build. For example, `builtins.readFile` can have the same effect.


All functions that query the filesystem will require a build when invoked on a derivation output path or subpath. This has the same effect and is therefore also called IFD. These include
All functions that query the filesystem will require a build when invoked on a derivation output path or subpath. This has the same effect and is therefore also called IFD. These include


* <code>import</code>
* <code>import (f drv)</code>
* <code>builtins.readFile</code>
* <code>builtins.readFile (f drv)</code>
* <code>builtins.readDir</code>
* <code>builtins.readDir (f drv)</code>
* <code>builtins.pathExists</code>
* <code>builtins.pathExists (f drv)</code>
* <code>builtins.filterSource</code>
* <code>builtins.filterSource g (f drv) </code>
* <code>builtins.path</code>
* <code>builtins.path { path = f drv; }</code>
* <code>builtins.hashFile</code>
* <code>builtins.hashFile t (f drv)</code>
* <code>builtins.scopedImport</code>
* <code>builtins.scopedImport x (f drv)</code>
* potentially other functions if those read the filesystem in any way
* potentially other functions if those read the filesystem in any way
* '''library functions''' that invoke the above, such as
* '''library functions''' that invoke the above, such as
* <code>lib.cleanSource</code>
* <code>lib.cleanSource { src = f drv; }</code>
* ...
* ...