From 3cfb8d15846238d79b36de7e52a90a4d3afa4268 Mon Sep 17 00:00:00 2001 From: Scott Olson Date: Mon, 15 Feb 2016 19:16:24 -0600 Subject: [PATCH 1/3] Remove unused global variable. --- nix-repl.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/nix-repl.cc b/nix-repl.cc index 1077f5d8f..8569b5eb6 100644 --- a/nix-repl.cc +++ b/nix-repl.cc @@ -19,9 +19,6 @@ using namespace std; using namespace nix; -string programId = "nix-repl"; - - struct NixRepl { string curDir; From 30a7bfbebe8582ab02f2a9b659403a5b3e1c097b Mon Sep 17 00:00:00 2001 From: Scott Olson Date: Mon, 15 Feb 2016 23:11:26 -0600 Subject: [PATCH 2/3] Fix grammar. --- nix-repl.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nix-repl.cc b/nix-repl.cc index 8569b5eb6..e753c637a 100644 --- a/nix-repl.cc +++ b/nix-repl.cc @@ -316,7 +316,7 @@ bool NixRepl::processLine(string line) evalString(arg, v); DrvInfo drvInfo(state); if (!getDerivation(state, v, drvInfo, false)) - throw Error("expression does not evaluation to a derivation, so I can't build it"); + throw Error("expression does not evaluate to a derivation, so I can't build it"); Path drvPath = drvInfo.queryDrvPath(); if (drvPath == "" || !store->isValidPath(drvPath)) throw Error("expression did not evaluate to a valid derivation"); From 82aca33899a0348736604e6b6a601f9c7b4e0633 Mon Sep 17 00:00:00 2001 From: Scott Olson Date: Tue, 16 Feb 2016 00:24:50 -0600 Subject: [PATCH 3/3] Add :i command to install a package to the current profile. It works by running `nix-env -i `. Fixes #15. --- nix-repl.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nix-repl.cc b/nix-repl.cc index e753c637a..ca221b033 100644 --- a/nix-repl.cc +++ b/nix-repl.cc @@ -281,6 +281,7 @@ bool NixRepl::processLine(string line) << " = Bind expression to variable\n" << " :a Add attributes from resulting set to scope\n" << " :b Build derivation\n" + << " :i Build derivation, then install result into current profile\n" << " :l Load Nix expression and add it to scope\n" << " :p Evaluate and print expression recursively\n" << " :q Exit nix-repl\n" @@ -311,7 +312,7 @@ bool NixRepl::processLine(string line) std::cout << showType(v) << std::endl; } - else if (command == ":b" || command == ":s") { + else if (command == ":b" || command == ":i" || command == ":s") { Value v; evalString(arg, v); DrvInfo drvInfo(state); @@ -331,8 +332,11 @@ bool NixRepl::processLine(string line) for (auto & i : drv.outputs) std::cout << format(" %1% -> %2%") % i.first % i.second.path << std::endl; } - } else + } else if (command == ":i") { + runProgram("nix-env", Strings{"-i", drvPath}); + } else { runProgram("nix-shell", Strings{drvPath}); + } } else if (command == ":p" || command == ":print") {