diff --git a/source/tutorials/nix-language.md b/source/tutorials/nix-language.md index 1b1b004..813c429 100644 --- a/source/tutorials/nix-language.md +++ b/source/tutorials/nix-language.md @@ -298,14 +298,9 @@ Nix language data types *without functions* work just like their counterparts in ::: - - - - - - - - - -
Nix languageJSON
+::::{grid} 2 +:::{grid-item} **Nix** ```nix { string = "hello"; @@ -322,10 +317,9 @@ Nix language data types *without functions* work just like their counterparts in }; # comments are supported } ``` +::: - - +:::{grid-item} **JSON** ```json { "string": "hello", @@ -342,10 +336,9 @@ Nix language data types *without functions* work just like their counterparts in } } ``` +::: -
+:::: :::{note} - Attribute names usually do not need quotes.[^attrnames] @@ -458,7 +451,7 @@ a + b 3 ``` -:::{dropdown} Detailed explanation +:::::{dropdown} Detailed explanation Assignments are placed between the keywords `let` and `in`. In this example we assign `a = 1` and `b = a + 1`. @@ -493,21 +486,9 @@ in both, the order of assignments does not matter, and names on the left can be Example: - - - - - - - - - -
+::::{grid} 2 -`let ... in ...` - - - -`rec { ... }` - -
+:::{grid-item} `let ... in ...` ```{code-block} nix :class: expression @@ -522,8 +503,10 @@ in { c = c; a = a; b = b; } :class: value { a = 1; b = 2; c = 3; } ``` - + +::: + +:::{grid-item} `rec { ... }` ```{code-block} nix :class: expression @@ -538,9 +521,10 @@ rec { :class: value { a = 1; b = 2; c = 3; } ``` -
+ +::: + +:::: The difference is that while a recursive attribute set evaluates to an [attribute set](attrset), any expression can follow after the `in` keyword. @@ -559,7 +543,8 @@ in [ a b c ] :class: value [ 1 2 3 ] ``` -::: + +::::: Only expressions within the `let` expression itself can access the newly declared names. We say: the bindings have local scope.