about summary refs log tree commit diff
path: root/src/nix/eval.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-09-07T18·37+0200
committerEelco Dolstra <edolstra@gmail.com>2017-09-07T18·37+0200
commit4967f0509aca0001156d937f36ed8eb17c72d752 (patch)
tree6837ba3068d093e4ffb4e217fef09daf96e51053 /src/nix/eval.cc
parent2ebeffcfd46f4a471cf4e49130ec106cf8a88ff1 (diff)
nix eval: Add examples
Diffstat (limited to 'src/nix/eval.cc')
-rw-r--r--src/nix/eval.cc18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/nix/eval.cc b/src/nix/eval.cc
index 981cefa800c4..e22128692630 100644
--- a/src/nix/eval.cc
+++ b/src/nix/eval.cc
@@ -27,6 +27,24 @@ struct CmdEval : MixJSON, InstallablesCommand
         return "evaluate a Nix expression";
     }
 
+    Examples examples() override
+    {
+        return {
+            Example{
+                "To evaluate a Nix expression given on the command line:",
+                "nix eval '(1 + 2)'"
+            },
+            Example{
+                "To evaluate a Nix expression from a file or URI:",
+                "nix eval -f channel:nixos-17.09 hello.name"
+            },
+            Example{
+                "To get the current version of Nixpkgs:",
+                "nix eval --raw nixpkgs.lib.nixpkgsVersion"
+            },
+        };
+    }
+
     void run(ref<Store> store) override
     {
         if (raw && json)