From f5f29dc2b7c266875fb9cbb0c8d5cdde3ac4a73c Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 20 Nov 2017 18:27:29 +0100 Subject: [PATCH] nix eval --raw: Use coerceToString() Thus, $ nix eval --raw '("foo")' foo $ nix eval --raw nixpkgs.hello /nix/store/1y6ckg6khrdsvll54s5spcmf3w6ka9k4-hello-2.10 $ nix eval --raw '(/etc/resolv.conf)' /nix/store/vml92ama92i8mz013nny461mlvg8mvap-resolv.conf --- src/nix/eval.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/nix/eval.cc b/src/nix/eval.cc index e22128692..0fbeca1c1 100644 --- a/src/nix/eval.cc +++ b/src/nix/eval.cc @@ -42,6 +42,10 @@ struct CmdEval : MixJSON, InstallablesCommand "To get the current version of Nixpkgs:", "nix eval --raw nixpkgs.lib.nixpkgsVersion" }, + Example{ + "To print the store path of the Hello package:", + "nix eval --raw nixpkgs.hello" + }, }; } @@ -56,10 +60,10 @@ struct CmdEval : MixJSON, InstallablesCommand for (auto & i : installables) { auto v = i->toValue(*state); + PathSet context; if (raw) { - std::cout << state->forceString(*v); + std::cout << state->coerceToString(noPos, *v, context); } else if (json) { - PathSet context; auto jsonElem = jsonOut->placeholder(); printValueAsJSON(*state, true, *v, jsonElem, context); } else {