From 39d72640c2459dc2fa689bfe8b756ee193f7b98a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 26 May 2014 16:50:36 +0200 Subject: Ensure that -I flags get included in nixPath Also fixes #261. --- src/libexpr/common-opts.cc | 4 ++-- src/libexpr/common-opts.hh | 4 ++-- src/libexpr/eval.cc | 7 +++---- src/libexpr/eval.hh | 3 +-- src/libexpr/parser.y | 2 +- 5 files changed, 9 insertions(+), 11 deletions(-) (limited to 'src/libexpr') diff --git a/src/libexpr/common-opts.cc b/src/libexpr/common-opts.cc index 9b3421f6c4..14a75f7b6f 100644 --- a/src/libexpr/common-opts.cc +++ b/src/libexpr/common-opts.cc @@ -35,11 +35,11 @@ bool parseOptionArg(const string & arg, Strings::iterator & i, bool parseSearchPathArg(const string & arg, Strings::iterator & i, - const Strings::iterator & argsEnd, EvalState & state) + const Strings::iterator & argsEnd, Strings & searchPath) { if (arg != "-I") return false; if (i == argsEnd) throw UsageError(format("`%1%' requires an argument") % arg);; - state.addToSearchPath(*i++, true); + searchPath.push_back(*i++); return true; } diff --git a/src/libexpr/common-opts.hh b/src/libexpr/common-opts.hh index e2e3fe7717..759358950f 100644 --- a/src/libexpr/common-opts.hh +++ b/src/libexpr/common-opts.hh @@ -8,9 +8,9 @@ namespace nix { bool parseOptionArg(const string & arg, Strings::iterator & i, const Strings::iterator & argsEnd, EvalState & state, Bindings & autoArgs); - + bool parseSearchPathArg(const string & arg, Strings::iterator & i, - const Strings::iterator & argsEnd, EvalState & state); + const Strings::iterator & argsEnd, Strings & searchPath); Path lookupFileArg(EvalState & state, string s); diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 81abe5b618..b6b69c2bdb 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -153,7 +153,7 @@ static Symbol getName(const AttrName & name, EvalState & state, Env & env) } -EvalState::EvalState() +EvalState::EvalState(const Strings & _searchPath) : sWith(symbols.create("")) , sOutPath(symbols.create("outPath")) , sDrvPath(symbols.create("drvPath")) @@ -219,11 +219,10 @@ EvalState::EvalState() #endif /* Initialise the Nix expression search path. */ - searchPathInsertionPoint = searchPath.end(); Strings paths = tokenizeString(getEnv("NIX_PATH", ""), ":"); - foreach (Strings::iterator, i, paths) addToSearchPath(*i); + for (auto & i : _searchPath) addToSearchPath(i); + for (auto & i : paths) addToSearchPath(i); addToSearchPath("nix=" + settings.nixDataDir + "/nix/corepkgs"); - searchPathInsertionPoint = searchPath.begin(); createBaseEnv(); } diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh index ad4c6a4b5f..200ec75e0f 100644 --- a/src/libexpr/eval.hh +++ b/src/libexpr/eval.hh @@ -113,11 +113,10 @@ private: typedef list > SearchPath; SearchPath searchPath; - SearchPath::iterator searchPathInsertionPoint; public: - EvalState(); + EvalState(const Strings & _searchPath); ~EvalState(); void addToSearchPath(const string & s, bool warn = false); diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y index 06d6d643f6..698e8ce3ff 100644 --- a/src/libexpr/parser.y +++ b/src/libexpr/parser.y @@ -629,7 +629,7 @@ void EvalState::addToSearchPath(const string & s, bool warn) path = absPath(path); if (pathExists(path)) { debug(format("adding path `%1%' to the search path") % path); - searchPath.insert(searchPathInsertionPoint, std::pair(prefix, path)); + searchPath.push_back(std::pair(prefix, path)); } else if (warn) printMsg(lvlError, format("warning: Nix search path entry `%1%' does not exist, ignoring") % path); } -- cgit 1.4.1