Nix Language Quirks: Difference between revisions

imported>Makefu
m fix syntax
imported>Danbst
Line 83: Line 83:
   ;
   ;
in
in
   removePrefix ... <syntaxHighlight>
   removePrefix ... </syntaxHighlight>


<code>inherit</code> has higher priority than <code>with</code>, and conflicts with <code>let</code>  
<code>inherit</code> has higher priority than <code>with</code>, and conflicts with <code>let</code>  
   <syntaxHighlight lang=nix>
   <syntaxHighlight lang=nix>
nix-repl> let pkgs = { x = 1; }; x = 2; x = 3; inherit (pkgs) x; in x
nix-repl> let pkgs = { x = 1; }; x = 2; x = 3; inherit (pkgs) x; in x
error: attribute ‘x’ at (string):1:31 already defined at (string):1:24 </syntaxHighlight>
error: attribute ‘x’ at (string):1:31 already defined at (string):1:24 </syntaxHighlight>
This makes it a sane citizen of Nix lanugage... except it has a twin, called <code>{ inherit ...; }</code>. They DON'T do the same - <code>let inherit ...</code> adds let-bindings, and <code>{ inherit ...; }</code> adds attributes to a record.
This makes it a sane citizen of Nix lanugage... except it has a twin, called <code>{ inherit ...; }</code>. They DON'T do the same - <code>let inherit ...</code> adds let-bindings, and <code>{ inherit ...; }</code> adds attributes to a record.
== Nix Language FAQ ==
== Nix Language FAQ ==
=== Q: What is the shortest <code>id</code> function definition? ===
=== Q: What is the shortest <code>id</code> function definition? ===