diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2014-08-26T18·03+0200 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2014-08-26T18·03+0200 |
commit | 89f9c0d41b29d18e2804677da856e84c86c83b45 (patch) | |
tree | 14c3b99b7db2f44dbd8d40eeb984b5a7dd20bf90 | |
parent | 02b66e97ba08ed68a73654556734aadfc9f41c89 (diff) |
Fix building against current Nix master
-rw-r--r-- | default.nix | 2 | ||||
-rw-r--r-- | nix-repl.cc | 30 |
2 files changed, 25 insertions, 7 deletions
diff --git a/default.nix b/default.nix index e7cdc23580e4..8690325e5289 100644 --- a/default.nix +++ b/default.nix @@ -2,6 +2,8 @@ with import nixpkgs { inherit system; }; +let nix = nixUnstable; in + runCommand "nix-repl" { buildInputs = [ readline nix boehmgc ]; } '' diff --git a/nix-repl.cc b/nix-repl.cc index fadaf079a8bd..bff54aa14f3a 100644 --- a/nix-repl.cc +++ b/nix-repl.cc @@ -39,7 +39,7 @@ struct NixRepl StringSet::iterator curCompletion; NixRepl(); - void mainLoop(const Strings & args); + void mainLoop(const Strings & files); void completePrefix(string prefix); bool getLine(string & line); bool processLine(string line); @@ -73,7 +73,7 @@ string removeWhitespace(string s) NixRepl::NixRepl() - : state(Strings()) + : state(Strings()) , staticEnv(false, &state.staticBaseEnv) { curDir = absPath("."); @@ -82,11 +82,11 @@ NixRepl::NixRepl() } -void NixRepl::mainLoop(const Strings & args) +void NixRepl::mainLoop(const Strings & files) { std::cout << "Welcome to Nix version " << NIX_VERSION << ". Type :? for help." << std::endl << std::endl; - foreach (Strings::const_iterator, i, args) + foreach (Strings::const_iterator, i, files) loadedFiles.push_back(*i); reloadFiles(); @@ -590,8 +590,24 @@ std::ostream & NixRepl::printValue(std::ostream & str, Value & v, unsigned int m } -void run(Strings args) +int main(int argc, char * * argv) { - NixRepl repl; - repl.mainLoop(args); + return handleExceptions(argv[0], [&]() { + initNix(); + + Strings files; + + parseCmdLine(argc, argv, [&](Strings::iterator & arg, const Strings::iterator & end) { + if (*arg == "--version") + printVersion("nix-repl"); + else if (*arg != "" && arg->at(0) == '-') + return false; + else + files.push_back(*arg); + return true; + }); + + NixRepl repl; + repl.mainLoop(files); + }); } |