Nix (language): Difference between revisions

imported>Samueldr
m quoting with blockquote
imported>Ixxie
Restructured page
Line 4: Line 4:
This [[:Category:Discussion|discussion]] article covers the syntax, semantics, typing, compilation, tooling and libraries of the Nix Expression Language.
This [[:Category:Discussion|discussion]] article covers the syntax, semantics, typing, compilation, tooling and libraries of the Nix Expression Language.


== Language Overview ==
<blockquote>The Nix expression language is a pure, lazy, functional language. Purity means that operations in the language don't have side-effects (for instance, there is no variable assignment). Laziness means that arguments to functions are evaluated only when they are needed. Functional means that functions are “normal” values that can be passed around and manipulated in interesting ways. The language is not a full-featured, general purpose language. Its main job is to describe packages, compositions of packages, and the variability within packages.</blockquote>
<blockquote>The Nix expression language is a pure, lazy, functional language. Purity means that operations in the language don't have side-effects (for instance, there is no variable assignment). Laziness means that arguments to functions are evaluated only when they are needed. Functional means that functions are “normal” values that can be passed around and manipulated in interesting ways. The language is not a full-featured, general purpose language. Its main job is to describe packages, compositions of packages, and the variability within packages.</blockquote>
<cite>— From the [https://nixos.org/nix/manual/#ch-expression-language nix manual]</cite>
<cite>— From the [https://nixos.org/nix/manual/#ch-expression-language nix manual]</cite>
Line 10: Line 9:
The language was designed especially for the [[Nix Package Manager]].
The language was designed especially for the [[Nix Package Manager]].


== Learning the Nix language ==
== Language Features ==


The [https://nixos.org/nix/manual/#ch-expression-language manual] provides a '''reference''' of the Nix language. All language constructs you may use in nix are defined here, together with code snippets.
TODO - feature overview
 
=== Expressions ===
 
TODO
 
=== Types ===
 
TODO
 
=== Functions ===


[https://medium.com/@MrJamesFisher/nix-by-example-a0063a1a4c55 Nix By Example] is a step-by-step tutorial.
TODO
The [https://nixos.org/nixos/nix-pills/index.html nix pills] also provide a lot of insight into the language and functional package management in general.


=== Notable Language Constructs ===
=== Notable Constructs ===
Nix looks a lot like JSON with functions but also provides a number of very specialized constructs which can help you build clean and easy to read expressions. In this sub-chapter the most notable constructs will be shown by example:
Nix looks a lot like JSON with functions but also provides a number of very specialized constructs which can help you build clean and easy to read expressions. In this sub-chapter the most notable constructs will be shown by example:


Line 114: Line 122:
TODO
TODO


== Syntax Highlighting/IDE Support ==
== Learning Resources ==
 
The [https://nixos.org/nix/manual/#ch-expression-language manual] provides a '''reference''' of the Nix language. All language constructs you may use in nix are defined here, together with code snippets.
 
[https://medium.com/@MrJamesFisher/nix-by-example-a0063a1a4c55 Nix By Example] is a step-by-step tutorial.
The [https://nixos.org/nixos/nix-pills/index.html nix pills] also provide a lot of insight into the language and functional package management in general.
 
== Development Tools ==
 
=== Syntax Highlighting & Editor Modes ===
 
Nix language has decent syntax highlighting (SH) support among popular code editors, but refactoring/autocomplete is still rare.
Nix language has decent syntax highlighting (SH) support among popular code editors, but refactoring/autocomplete is still rare.