# line comments
/* multiline
comments */
[
true # b
1 2 3.5
"hello"
{ k = "v"; k2 = "v2"; } # unorder
/tmp/file.nix ./file.nix
]
rec { a = "12"; b = "something" + a; c."k1"."${b}" = "value"; }
rec { a = 12; b = { k = b; }; }.b.k
''
multi line
${toString (10 + 15)}
string
with multiple lines''
if
is expression
if 3 > 5 then "greater" else "less"
a: { t = "test"; b = a; }
((a: a + 1) 2)
{a ? null, ...}@args: b: { result = args; }
- let
- inherit
- with
let
a = { b = { c = "1"; d = 2; }; };
in
with a;
{ inherit (b); }
import ./test.nix {}
let
lib = (import <nixpkgs> {}).lib;
in
{ ea = builtins.elemAt; lb = lib.strings; }
There is no loops, oops.
How to live without loops ideas:
- map
- filter
- foldl
#{ pkgs ? import <nixpkgs> {} }:
let
pkgs = import <nixpkgs> {};
newPkg = pkgs.writeText "hello.txt" "Hello world!";
# and different fetchSomething functions
in
"${builtins.getEnv "HOME"} and ${newPkg}"
{ config, pkgs, ...}:
{
options = {};
config = {};
}
Home-manager module example.