From 4967f0509aca0001156d937f36ed8eb17c72d752 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 7 Sep 2017 20:37:46 +0200 Subject: [PATCH] nix eval: Add examples --- src/nix/eval.cc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/nix/eval.cc b/src/nix/eval.cc index 981cefa80..e22128692 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) override { if (raw && json)