Nix (language): Difference between revisions
imported>Makefu →let ... in statement: init |
imported>Makefu |
||
Line 149: | Line 149: | ||
==== <code>inherit</code> statement ==== | ==== <code>inherit</code> statement ==== | ||
The <code>inherit</code> expression can be used to copy variables from the surrounding lexical scope. A typical use case is to declare the version or name of a derivation in the expression and reuse this parameter in the function to fetch the source. | |||
This is a typical python package derivation as the fetchPypi function also requires <code>pname</code> and <code>version</code> as input: | |||
<syntaxHighlight lang=nix> | |||
buildPythonPackage rec { | |||
pname = "hello"; | |||
version = "1.0"; | |||
src = fetchPypi { | |||
inherit pname version; | |||
sha256 = "01ba..0"; | |||
}; | |||
} | |||
</syntaxHighlight> | |||
==== <code>rec</code> statement ==== | ==== <code>rec</code> statement ==== | ||
TODO | TODO |