diff --git a/src/libcmd/command.cc b/src/libcmd/command.cc index 220a90cf6..543250da3 100644 --- a/src/libcmd/command.cc +++ b/src/libcmd/command.cc @@ -128,10 +128,10 @@ ref EvalCommand::getEvalState() evalState = #if HAVE_BOEHMGC std::allocate_shared(traceable_allocator(), - searchPath, getEvalStore(), getStore()) + lookupPath, getEvalStore(), getStore()) #else std::make_shared( - searchPath, getEvalStore(), getStore()) + lookupPath, getEvalStore(), getStore()) #endif ; diff --git a/src/libcmd/common-eval-args.cc b/src/libcmd/common-eval-args.cc index c6ee0d0b2..155b43b70 100644 --- a/src/libcmd/common-eval-args.cc +++ b/src/libcmd/common-eval-args.cc @@ -125,7 +125,7 @@ MixEvalArgs::MixEvalArgs() .category = category, .labels = {"path"}, .handler = {[&](std::string s) { - searchPath.elements.emplace_back(SearchPath::Elem::parse(s)); + lookupPath.elements.emplace_back(LookupPath::Elem::parse(s)); }} }); diff --git a/src/libcmd/common-eval-args.hh b/src/libcmd/common-eval-args.hh index 25ce5b9da..d2efea28e 100644 --- a/src/libcmd/common-eval-args.hh +++ b/src/libcmd/common-eval-args.hh @@ -23,7 +23,7 @@ struct MixEvalArgs : virtual Args, virtual MixRepair Bindings * getAutoArgs(EvalState & state); - SearchPath searchPath; + LookupPath lookupPath; std::optional evalStoreUrl; diff --git a/src/libcmd/repl.cc b/src/libcmd/repl.cc index ffbb43a69..a045e83d2 100644 --- a/src/libcmd/repl.cc +++ b/src/libcmd/repl.cc @@ -77,7 +77,7 @@ struct NixRepl std::unique_ptr interacter; - NixRepl(const SearchPath & searchPath, nix::ref store,ref state, + NixRepl(const LookupPath & lookupPath, nix::ref store,ref state, std::function getValues); virtual ~NixRepl() = default; @@ -122,7 +122,7 @@ std::string removeWhitespace(std::string s) } -NixRepl::NixRepl(const SearchPath & searchPath, nix::ref store, ref state, +NixRepl::NixRepl(const LookupPath & lookupPath, nix::ref store, ref state, std::function getValues) : AbstractNixRepl(state) , debugTraceIndex(0) @@ -508,7 +508,7 @@ ProcessLineResult NixRepl::processLine(std::string line) // runProgram redirects stdout to a StringSink, // using runProgram2 to allow editors to display their UI - runProgram2(RunOptions { .program = editor, .searchPath = true, .args = args }); + runProgram2(RunOptions { .program = editor, .lookupPath = true, .args = args }); // Reload right after exiting the editor state->resetFileCache(); @@ -784,11 +784,11 @@ void NixRepl::evalString(std::string s, Value & v) std::unique_ptr AbstractNixRepl::create( - const SearchPath & searchPath, nix::ref store, ref state, + const LookupPath & lookupPath, nix::ref store, ref state, std::function getValues) { return std::make_unique( - searchPath, + lookupPath, openStore(), state, getValues @@ -804,9 +804,9 @@ ReplExitStatus AbstractNixRepl::runSimple( NixRepl::AnnotatedValues values; return values; }; - SearchPath searchPath = {}; + LookupPath lookupPath = {}; auto repl = std::make_unique( - searchPath, + lookupPath, openStore(), evalState, getValues diff --git a/src/libcmd/repl.hh b/src/libcmd/repl.hh index aac79ec74..3fd4b2c39 100644 --- a/src/libcmd/repl.hh +++ b/src/libcmd/repl.hh @@ -20,7 +20,7 @@ struct AbstractNixRepl typedef std::vector> AnnotatedValues; static std::unique_ptr create( - const SearchPath & searchPath, nix::ref store, ref state, + const LookupPath & lookupPath, nix::ref store, ref state, std::function getValues); static ReplExitStatus runSimple( diff --git a/src/libexpr-c/nix_api_expr.cc b/src/libexpr-c/nix_api_expr.cc index a5c03d5aa..a29c3425e 100644 --- a/src/libexpr-c/nix_api_expr.cc +++ b/src/libexpr-c/nix_api_expr.cc @@ -85,17 +85,17 @@ nix_err nix_value_force_deep(nix_c_context * context, EvalState * state, Value * NIXC_CATCH_ERRS } -EvalState * nix_state_create(nix_c_context * context, const char ** searchPath_c, Store * store) +EvalState * nix_state_create(nix_c_context * context, const char ** lookupPath_c, Store * store) { if (context) context->last_err_code = NIX_OK; try { - nix::Strings searchPath; - if (searchPath_c != nullptr) - for (size_t i = 0; searchPath_c[i] != nullptr; i++) - searchPath.push_back(searchPath_c[i]); + nix::Strings lookupPath; + if (lookupPath_c != nullptr) + for (size_t i = 0; lookupPath_c[i] != nullptr; i++) + lookupPath.push_back(lookupPath_c[i]); - return new EvalState{nix::EvalState(nix::SearchPath::parse(searchPath), store->ptr)}; + return new EvalState{nix::EvalState(nix::LookupPath::parse(lookupPath), store->ptr)}; } NIXC_CATCH_ERRS_NULL } diff --git a/src/libexpr-c/nix_api_expr.h b/src/libexpr-c/nix_api_expr.h index fd9746ab7..04fc92f0f 100644 --- a/src/libexpr-c/nix_api_expr.h +++ b/src/libexpr-c/nix_api_expr.h @@ -140,11 +140,11 @@ nix_err nix_value_force_deep(nix_c_context * context, EvalState * state, Value * * @brief Create a new Nix language evaluator state. * * @param[out] context Optional, stores error information - * @param[in] searchPath Array of strings corresponding to entries in NIX_PATH. + * @param[in] lookupPath Array of strings corresponding to entries in NIX_PATH. * @param[in] store The Nix store to use. * @return A new Nix state or NULL on failure. */ -EvalState * nix_state_create(nix_c_context * context, const char ** searchPath, Store * store); +EvalState * nix_state_create(nix_c_context * context, const char ** lookupPath, Store * store); /** * @brief Frees a Nix state. diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 72da1c465..35ccca79a 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -343,7 +343,7 @@ void initGC() } EvalState::EvalState( - const SearchPath & _searchPath, + const LookupPath & _lookupPath, ref store, std::shared_ptr buildStore) : sWith(symbols.create("")) @@ -448,16 +448,16 @@ EvalState::EvalState( /* Initialise the Nix expression search path. */ if (!evalSettings.pureEval) { - for (auto & i : _searchPath.elements) - searchPath.elements.emplace_back(SearchPath::Elem {i}); + for (auto & i : _lookupPath.elements) + lookupPath.elements.emplace_back(LookupPath::Elem {i}); for (auto & i : evalSettings.nixPath.get()) - searchPath.elements.emplace_back(SearchPath::Elem::parse(i)); + lookupPath.elements.emplace_back(LookupPath::Elem::parse(i)); } /* Allow access to all paths in the search path. */ if (rootFS.dynamic_pointer_cast()) - for (auto & i : searchPath.elements) - resolveSearchPathPath(i.path, true); + for (auto & i : lookupPath.elements) + resolveLookupPathPath(i.path, true); corepkgsFS->addFile( CanonPath("fetchurl.nix"), @@ -2820,19 +2820,19 @@ Expr * EvalState::parseStdin() SourcePath EvalState::findFile(const std::string_view path) { - return findFile(searchPath, path); + return findFile(lookupPath, path); } -SourcePath EvalState::findFile(const SearchPath & searchPath, const std::string_view path, const PosIdx pos) +SourcePath EvalState::findFile(const LookupPath & lookupPath, const std::string_view path, const PosIdx pos) { - for (auto & i : searchPath.elements) { + for (auto & i : lookupPath.elements) { auto suffixOpt = i.prefix.suffixIfPotentialMatch(path); if (!suffixOpt) continue; auto suffix = *suffixOpt; - auto rOpt = resolveSearchPathPath(i.path); + auto rOpt = resolveLookupPathPath(i.path); if (!rOpt) continue; auto r = *rOpt; @@ -2852,11 +2852,11 @@ SourcePath EvalState::findFile(const SearchPath & searchPath, const std::string_ } -std::optional EvalState::resolveSearchPathPath(const SearchPath::Path & value0, bool initAccessControl) +std::optional EvalState::resolveLookupPathPath(const LookupPath::Path & value0, bool initAccessControl) { auto & value = value0.s; - auto i = searchPathResolved.find(value); - if (i != searchPathResolved.end()) return i->second; + auto i = lookupPathResolved.find(value); + if (i != lookupPathResolved.end()) return i->second; std::optional res; @@ -2912,7 +2912,7 @@ std::optional EvalState::resolveSearchPathPath(const SearchPath::Pa else debug("failed to resolve search path element '%s'", value); - searchPathResolved.emplace(value, res); + lookupPathResolved.emplace(value, res); return res; } diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh index af65fdcba..b62c994ad 100644 --- a/src/libexpr/eval.hh +++ b/src/libexpr/eval.hh @@ -162,7 +162,7 @@ struct DebugTrace { }; // Don't want Windows function -#undef SearchPath +#undef LookupPath class EvalState : public std::enable_shared_from_this { @@ -311,9 +311,9 @@ private: #endif FileEvalCache fileEvalCache; - SearchPath searchPath; + LookupPath lookupPath; - std::map> searchPathResolved; + std::map> lookupPathResolved; /** * Cache used by prim_match(). @@ -335,12 +335,12 @@ private: public: EvalState( - const SearchPath & _searchPath, + const LookupPath & _lookupPath, ref store, std::shared_ptr buildStore = nullptr); ~EvalState(); - SearchPath getSearchPath() { return searchPath; } + LookupPath getLookupPath() { return lookupPath; } /** * Return a `SourcePath` that refers to `path` in the root @@ -409,7 +409,7 @@ public: * Look up a file in the search path. */ SourcePath findFile(const std::string_view path); - SourcePath findFile(const SearchPath & searchPath, const std::string_view path, const PosIdx pos = noPos); + SourcePath findFile(const LookupPath & lookupPath, const std::string_view path, const PosIdx pos = noPos); /** * Try to resolve a search path value (not the optional key part). @@ -418,8 +418,8 @@ public: * * If it is not found, return `std::nullopt` */ - std::optional resolveSearchPathPath( - const SearchPath::Path & elem, + std::optional resolveLookupPathPath( + const LookupPath::Path & elem, bool initAccessControl = false); /** diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index f03acc2da..df274caed 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -1716,7 +1716,7 @@ static void prim_findFile(EvalState & state, const PosIdx pos, Value * * args, V { state.forceList(*args[0], pos, "while evaluating the first argument passed to builtins.findFile"); - SearchPath searchPath; + LookupPath lookupPath; for (auto v2 : args[0]->listItems()) { state.forceAttrs(*v2, pos, "while evaluating an element of the list passed to builtins.findFile"); @@ -1744,15 +1744,15 @@ static void prim_findFile(EvalState & state, const PosIdx pos, Value * * args, V ).atPos(pos).debugThrow(); } - searchPath.elements.emplace_back(SearchPath::Elem { - .prefix = SearchPath::Prefix { .s = prefix }, - .path = SearchPath::Path { .s = path }, + lookupPath.elements.emplace_back(LookupPath::Elem { + .prefix = LookupPath::Prefix { .s = prefix }, + .path = LookupPath::Path { .s = path }, }); } auto path = state.forceStringNoCtx(*args[1], pos, "while evaluating the second argument passed to builtins.findFile"); - v.mkPath(state.findFile(searchPath, path, pos)); + v.mkPath(state.findFile(lookupPath, path, pos)); } static RegisterPrimOp primop_findFile(PrimOp { @@ -4629,8 +4629,8 @@ void EvalState::createBaseEnv() }); /* Add a value containing the current Nix expression search path. */ - auto list = buildList(searchPath.elements.size()); - for (const auto & [n, i] : enumerate(searchPath.elements)) { + auto list = buildList(lookupPath.elements.size()); + for (const auto & [n, i] : enumerate(lookupPath.elements)) { auto attrs = buildBindings(2); attrs.alloc("path").mkString(i.path.s); attrs.alloc("prefix").mkString(i.prefix.s); diff --git a/src/libexpr/search-path.cc b/src/libexpr/search-path.cc index e2c3e050a..657744e74 100644 --- a/src/libexpr/search-path.cc +++ b/src/libexpr/search-path.cc @@ -2,7 +2,7 @@ namespace nix { -std::optional SearchPath::Prefix::suffixIfPotentialMatch( +std::optional LookupPath::Prefix::suffixIfPotentialMatch( std::string_view path) const { auto n = s.size(); @@ -27,11 +27,11 @@ std::optional SearchPath::Prefix::suffixIfPotentialMatch( } -SearchPath::Elem SearchPath::Elem::parse(std::string_view rawElem) +LookupPath::Elem LookupPath::Elem::parse(std::string_view rawElem) { size_t pos = rawElem.find('='); - return SearchPath::Elem { + return LookupPath::Elem { .prefix = Prefix { .s = pos == std::string::npos ? std::string { "" } @@ -44,11 +44,11 @@ SearchPath::Elem SearchPath::Elem::parse(std::string_view rawElem) } -SearchPath SearchPath::parse(const Strings & rawElems) +LookupPath LookupPath::parse(const Strings & rawElems) { - SearchPath res; + LookupPath res; for (auto & rawElem : rawElems) - res.elements.emplace_back(SearchPath::Elem::parse(rawElem)); + res.elements.emplace_back(LookupPath::Elem::parse(rawElem)); return res; } diff --git a/src/libexpr/search-path.hh b/src/libexpr/search-path.hh index 231752ea6..6a63f3730 100644 --- a/src/libexpr/search-path.hh +++ b/src/libexpr/search-path.hh @@ -8,17 +8,17 @@ namespace nix { -// Do not want the windows macro (alias to `SearchPathA`) -#undef SearchPath +// Do not want the windows macro (alias to `LookupPathA`) +#undef LookupPath /** * A "search path" is a list of ways look for something, used with * `builtins.findFile` and `< >` lookup expressions. */ -struct SearchPath +struct LookupPath { /** - * A single element of a `SearchPath`. + * A single element of a `LookupPath`. * * Each element is tried in succession when looking up a path. The first * element to completely match wins. @@ -26,16 +26,16 @@ struct SearchPath struct Elem; /** - * The first part of a `SearchPath::Elem` pair. + * The first part of a `LookupPath::Elem` pair. * * Called a "prefix" because it takes the form of a prefix of a file * path (first `n` path components). When looking up a path, to use - * a `SearchPath::Elem`, its `Prefix` must match the path. + * a `LookupPath::Elem`, its `Prefix` must match the path. */ struct Prefix; /** - * The second part of a `SearchPath::Elem` pair. + * The second part of a `LookupPath::Elem` pair. * * It is either a path or a URL (with certain restrictions / extra * structure). @@ -43,7 +43,7 @@ struct SearchPath * If the prefix of the path we are looking up matches, we then * check if the rest of the path points to something that exists * within the directory denoted by this. If so, the - * `SearchPath::Elem` as a whole matches, and that *something* being + * `LookupPath::Elem` as a whole matches, and that *something* being * pointed to by the rest of the path we are looking up is the * result. */ @@ -54,24 +54,24 @@ struct SearchPath * when looking up. (The actual lookup entry point is in `EvalState` * not in this class.) */ - std::list elements; + std::list elements; /** - * Parse a string into a `SearchPath` + * Parse a string into a `LookupPath` */ - static SearchPath parse(const Strings & rawElems); + static LookupPath parse(const Strings & rawElems); }; -struct SearchPath::Prefix +struct LookupPath::Prefix { /** * Underlying string * - * @todo Should we normalize this when constructing a `SearchPath::Prefix`? + * @todo Should we normalize this when constructing a `LookupPath::Prefix`? */ std::string s; - GENERATE_CMP(SearchPath::Prefix, me->s); + GENERATE_CMP(LookupPath::Prefix, me->s); /** * If the path possibly matches this search path element, return the @@ -82,7 +82,7 @@ struct SearchPath::Prefix std::optional suffixIfPotentialMatch(std::string_view path) const; }; -struct SearchPath::Path +struct LookupPath::Path { /** * The location of a search path item, as a path or URL. @@ -91,21 +91,21 @@ struct SearchPath::Path */ std::string s; - GENERATE_CMP(SearchPath::Path, me->s); + GENERATE_CMP(LookupPath::Path, me->s); }; -struct SearchPath::Elem +struct LookupPath::Elem { Prefix prefix; Path path; - GENERATE_CMP(SearchPath::Elem, me->prefix, me->path); + GENERATE_CMP(LookupPath::Elem, me->prefix, me->path); /** - * Parse a string into a `SearchPath::Elem` + * Parse a string into a `LookupPath::Elem` */ - static SearchPath::Elem parse(std::string_view rawElem); + static LookupPath::Elem parse(std::string_view rawElem); }; } diff --git a/src/libfetchers/git-utils.cc b/src/libfetchers/git-utils.cc index a4a00374c..e310af063 100644 --- a/src/libfetchers/git-utils.cc +++ b/src/libfetchers/git-utils.cc @@ -385,7 +385,7 @@ struct GitRepoImpl : GitRepo, std::enable_shared_from_this runProgram(RunOptions { .program = "git", - .searchPath = true, + .lookupPath = true, // FIXME: git stderr messes up our progress indicator, so // we're using --quiet for now. Should process its stderr. .args = gitArgs, diff --git a/src/libfetchers/unix/mercurial.cc b/src/libfetchers/unix/mercurial.cc index 4e0b26274..df6bc5335 100644 --- a/src/libfetchers/unix/mercurial.cc +++ b/src/libfetchers/unix/mercurial.cc @@ -24,7 +24,7 @@ static RunOptions hgOptions(const Strings & args) return { .program = "hg", - .searchPath = true, + .lookupPath = true, .args = args, .environment = env }; diff --git a/src/libstore/unix/build/local-derivation-goal.cc b/src/libstore/unix/build/local-derivation-goal.cc index aad5173e7..72125cb82 100644 --- a/src/libstore/unix/build/local-derivation-goal.cc +++ b/src/libstore/unix/build/local-derivation-goal.cc @@ -77,7 +77,7 @@ void handleDiffHook( try { auto diffRes = runProgram(RunOptions { .program = diffHook, - .searchPath = true, + .lookupPath = true, .args = {tryA, tryB, drvPath, tmpDir}, .uid = uid, .gid = gid, diff --git a/src/libutil/processes.hh b/src/libutil/processes.hh index a7e85b5be..e319f79e0 100644 --- a/src/libutil/processes.hh +++ b/src/libutil/processes.hh @@ -80,14 +80,14 @@ pid_t startProcess(std::function fun, const ProcessOptions & options = P * Run a program and return its stdout in a string (i.e., like the * shell backtick operator). */ -std::string runProgram(Path program, bool searchPath = false, +std::string runProgram(Path program, bool lookupPath = false, const Strings & args = Strings(), const std::optional & input = {}, bool isInteractive = false); struct RunOptions { Path program; - bool searchPath = true; + bool lookupPath = true; Strings args; #ifndef _WIN32 std::optional uid; diff --git a/src/libutil/unix/processes.cc b/src/libutil/unix/processes.cc index f5d584330..1af559a21 100644 --- a/src/libutil/unix/processes.cc +++ b/src/libutil/unix/processes.cc @@ -245,10 +245,10 @@ pid_t startProcess(std::function fun, const ProcessOptions & options) } -std::string runProgram(Path program, bool searchPath, const Strings & args, +std::string runProgram(Path program, bool lookupPath, const Strings & args, const std::optional & input, bool isInteractive) { - auto res = runProgram(RunOptions {.program = program, .searchPath = searchPath, .args = args, .input = input, .isInteractive = isInteractive}); + auto res = runProgram(RunOptions {.program = program, .lookupPath = lookupPath, .args = args, .input = input, .isInteractive = isInteractive}); if (!statusOk(res.first)) throw ExecError(res.first, "program '%1%' %2%", program, statusToString(res.first)); @@ -335,7 +335,7 @@ void runProgram2(const RunOptions & options) restoreProcessContext(); - if (options.searchPath) + if (options.lookupPath) execvp(options.program.c_str(), stringsToCharPtrs(args_).data()); // This allows you to refer to a program with a pathname relative // to the PATH variable. diff --git a/src/libutil/windows/processes.cc b/src/libutil/windows/processes.cc index 2a5377f3f..5ef4ed1e4 100644 --- a/src/libutil/windows/processes.cc +++ b/src/libutil/windows/processes.cc @@ -28,7 +28,7 @@ namespace nix { -std::string runProgram(Path program, bool searchPath, const Strings & args, +std::string runProgram(Path program, bool lookupPath, const Strings & args, const std::optional & input, bool isInteractive) { throw UnimplementedError("Cannot shell out to git on Windows yet"); diff --git a/src/nix-build/nix-build.cc b/src/nix-build/nix-build.cc index 198e9cda0..30ebc9498 100644 --- a/src/nix-build/nix-build.cc +++ b/src/nix-build/nix-build.cc @@ -258,7 +258,7 @@ static void main_nix_build(int argc, char * * argv) auto store = openStore(); auto evalStore = myArgs.evalStoreUrl ? openStore(*myArgs.evalStoreUrl) : store; - auto state = std::make_unique(myArgs.searchPath, evalStore, store); + auto state = std::make_unique(myArgs.lookupPath, evalStore, store); state->repair = myArgs.repair; if (myArgs.repair) buildMode = bmRepair; diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc index eeca01833..25c8f43c2 100644 --- a/src/nix-env/nix-env.cc +++ b/src/nix-env/nix-env.cc @@ -1525,7 +1525,7 @@ static int main_nix_env(int argc, char * * argv) auto store = openStore(); - globals.state = std::shared_ptr(new EvalState(myArgs.searchPath, store)); + globals.state = std::shared_ptr(new EvalState(myArgs.lookupPath, store)); globals.state->repair = myArgs.repair; globals.instSource.nixExprPath = std::make_shared( diff --git a/src/nix-instantiate/nix-instantiate.cc b/src/nix-instantiate/nix-instantiate.cc index 1e1728225..35664374c 100644 --- a/src/nix-instantiate/nix-instantiate.cc +++ b/src/nix-instantiate/nix-instantiate.cc @@ -157,7 +157,7 @@ static int main_nix_instantiate(int argc, char * * argv) auto store = openStore(); auto evalStore = myArgs.evalStoreUrl ? openStore(*myArgs.evalStoreUrl) : store; - auto state = std::make_unique(myArgs.searchPath, evalStore, store); + auto state = std::make_unique(myArgs.lookupPath, evalStore, store); state->repair = myArgs.repair; Bindings & autoArgs = *myArgs.getAutoArgs(*state); diff --git a/src/nix/develop.cc b/src/nix/develop.cc index 35d3da912..f2df814d7 100644 --- a/src/nix/develop.cc +++ b/src/nix/develop.cc @@ -687,7 +687,7 @@ struct CmdDevelop : Common, MixEnvironment } } - runProgramInStore(store, UseSearchPath::Use, shell, args, buildEnvironment.getSystem()); + runProgramInStore(store, UseLookupPath::Use, shell, args, buildEnvironment.getSystem()); #endif } }; diff --git a/src/nix/fmt.cc b/src/nix/fmt.cc index 059904150..4b0fbb89d 100644 --- a/src/nix/fmt.cc +++ b/src/nix/fmt.cc @@ -49,7 +49,7 @@ struct CmdFmt : SourceExprCommand { } } - runProgramInStore(store, UseSearchPath::DontUse, app.program, programArgs); + runProgramInStore(store, UseLookupPath::DontUse, app.program, programArgs); }; }; diff --git a/src/nix/prefetch.cc b/src/nix/prefetch.cc index 8e6a2e805..f905cabef 100644 --- a/src/nix/prefetch.cc +++ b/src/nix/prefetch.cc @@ -193,7 +193,7 @@ static int main_nix_prefetch_url(int argc, char * * argv) startProgressBar(); auto store = openStore(); - auto state = std::make_unique(myArgs.searchPath, store); + auto state = std::make_unique(myArgs.lookupPath, store); Bindings & autoArgs = *myArgs.getAutoArgs(*state); diff --git a/src/nix/repl.cc b/src/nix/repl.cc index 8bbfe0f07..a2f3e033e 100644 --- a/src/nix/repl.cc +++ b/src/nix/repl.cc @@ -78,7 +78,7 @@ struct CmdRepl : RawInstallablesCommand return values; }; auto repl = AbstractNixRepl::create( - searchPath, + lookupPath, openStore(), state, getValues diff --git a/src/nix/run.cc b/src/nix/run.cc index c45683302..88821710d 100644 --- a/src/nix/run.cc +++ b/src/nix/run.cc @@ -25,7 +25,7 @@ std::string chrootHelperName = "__run_in_chroot"; namespace nix { void runProgramInStore(ref store, - UseSearchPath useSearchPath, + UseLookupPath useLookupPath, const std::string & program, const Strings & args, std::optional system) @@ -61,7 +61,7 @@ void runProgramInStore(ref store, linux::setPersonality(*system); #endif - if (useSearchPath == UseSearchPath::Use) + if (useLookupPath == UseLookupPath::Use) execvp(program.c_str(), stringsToCharPtrs(args).data()); else execv(program.c_str(), stringsToCharPtrs(args).data()); @@ -142,7 +142,7 @@ struct CmdShell : InstallablesCommand, MixEnvironment Strings args; for (auto & arg : command) args.push_back(arg); - runProgramInStore(store, UseSearchPath::Use, *command.begin(), args); + runProgramInStore(store, UseLookupPath::Use, *command.begin(), args); } }; @@ -204,7 +204,7 @@ struct CmdRun : InstallableValueCommand Strings allArgs{app.program}; for (auto & i : args) allArgs.push_back(i); - runProgramInStore(store, UseSearchPath::DontUse, app.program, allArgs); + runProgramInStore(store, UseLookupPath::DontUse, app.program, allArgs); } }; diff --git a/src/nix/run.hh b/src/nix/run.hh index a55917b06..2fe6ed86a 100644 --- a/src/nix/run.hh +++ b/src/nix/run.hh @@ -5,13 +5,13 @@ namespace nix { -enum struct UseSearchPath { +enum struct UseLookupPath { Use, DontUse }; void runProgramInStore(ref store, - UseSearchPath useSearchPath, + UseLookupPath useLookupPath, const std::string & program, const Strings & args, std::optional system = std::nullopt); diff --git a/src/nix/upgrade-nix.cc b/src/nix/upgrade-nix.cc index 4c7a74e16..a64b6a56e 100644 --- a/src/nix/upgrade-nix.cc +++ b/src/nix/upgrade-nix.cc @@ -147,7 +147,7 @@ struct CmdUpgradeNix : MixDryRun, StoreCommand auto req = FileTransferRequest((std::string&) settings.upgradeNixStorePathUrl); auto res = getFileTransfer()->download(req); - auto state = std::make_unique(SearchPath{}, store); + auto state = std::make_unique(LookupPath{}, store); auto v = state->allocValue(); state->eval(state->parseExprFromString(res.data, state->rootPath(CanonPath("/no-such-path"))), *v); Bindings & bindings(*state->allocBindings(0)); diff --git a/tests/unit/libexpr/search-path.cc b/tests/unit/libexpr/search-path.cc index dbe7ab95f..080679355 100644 --- a/tests/unit/libexpr/search-path.cc +++ b/tests/unit/libexpr/search-path.cc @@ -5,85 +5,85 @@ namespace nix { -TEST(SearchPathElem, parse_justPath) { +TEST(LookupPathElem, parse_justPath) { ASSERT_EQ( - SearchPath::Elem::parse("foo"), - (SearchPath::Elem { - .prefix = SearchPath::Prefix { .s = "" }, - .path = SearchPath::Path { .s = "foo" }, + LookupPath::Elem::parse("foo"), + (LookupPath::Elem { + .prefix = LookupPath::Prefix { .s = "" }, + .path = LookupPath::Path { .s = "foo" }, })); } -TEST(SearchPathElem, parse_emptyPrefix) { +TEST(LookupPathElem, parse_emptyPrefix) { ASSERT_EQ( - SearchPath::Elem::parse("=foo"), - (SearchPath::Elem { - .prefix = SearchPath::Prefix { .s = "" }, - .path = SearchPath::Path { .s = "foo" }, + LookupPath::Elem::parse("=foo"), + (LookupPath::Elem { + .prefix = LookupPath::Prefix { .s = "" }, + .path = LookupPath::Path { .s = "foo" }, })); } -TEST(SearchPathElem, parse_oneEq) { +TEST(LookupPathElem, parse_oneEq) { ASSERT_EQ( - SearchPath::Elem::parse("foo=bar"), - (SearchPath::Elem { - .prefix = SearchPath::Prefix { .s = "foo" }, - .path = SearchPath::Path { .s = "bar" }, + LookupPath::Elem::parse("foo=bar"), + (LookupPath::Elem { + .prefix = LookupPath::Prefix { .s = "foo" }, + .path = LookupPath::Path { .s = "bar" }, })); } -TEST(SearchPathElem, parse_twoEqs) { +TEST(LookupPathElem, parse_twoEqs) { ASSERT_EQ( - SearchPath::Elem::parse("foo=bar=baz"), - (SearchPath::Elem { - .prefix = SearchPath::Prefix { .s = "foo" }, - .path = SearchPath::Path { .s = "bar=baz" }, + LookupPath::Elem::parse("foo=bar=baz"), + (LookupPath::Elem { + .prefix = LookupPath::Prefix { .s = "foo" }, + .path = LookupPath::Path { .s = "bar=baz" }, })); } -TEST(SearchPathElem, suffixIfPotentialMatch_justPath) { - SearchPath::Prefix prefix { .s = "" }; +TEST(LookupPathElem, suffixIfPotentialMatch_justPath) { + LookupPath::Prefix prefix { .s = "" }; ASSERT_EQ(prefix.suffixIfPotentialMatch("any/thing"), std::optional { "any/thing" }); } -TEST(SearchPathElem, suffixIfPotentialMatch_misleadingPrefix1) { - SearchPath::Prefix prefix { .s = "foo" }; +TEST(LookupPathElem, suffixIfPotentialMatch_misleadingPrefix1) { + LookupPath::Prefix prefix { .s = "foo" }; ASSERT_EQ(prefix.suffixIfPotentialMatch("fooX"), std::nullopt); } -TEST(SearchPathElem, suffixIfPotentialMatch_misleadingPrefix2) { - SearchPath::Prefix prefix { .s = "foo" }; +TEST(LookupPathElem, suffixIfPotentialMatch_misleadingPrefix2) { + LookupPath::Prefix prefix { .s = "foo" }; ASSERT_EQ(prefix.suffixIfPotentialMatch("fooX/bar"), std::nullopt); } -TEST(SearchPathElem, suffixIfPotentialMatch_partialPrefix) { - SearchPath::Prefix prefix { .s = "fooX" }; +TEST(LookupPathElem, suffixIfPotentialMatch_partialPrefix) { + LookupPath::Prefix prefix { .s = "fooX" }; ASSERT_EQ(prefix.suffixIfPotentialMatch("foo"), std::nullopt); } -TEST(SearchPathElem, suffixIfPotentialMatch_exactPrefix) { - SearchPath::Prefix prefix { .s = "foo" }; +TEST(LookupPathElem, suffixIfPotentialMatch_exactPrefix) { + LookupPath::Prefix prefix { .s = "foo" }; ASSERT_EQ(prefix.suffixIfPotentialMatch("foo"), std::optional { "" }); } -TEST(SearchPathElem, suffixIfPotentialMatch_multiKey) { - SearchPath::Prefix prefix { .s = "foo/bar" }; +TEST(LookupPathElem, suffixIfPotentialMatch_multiKey) { + LookupPath::Prefix prefix { .s = "foo/bar" }; ASSERT_EQ(prefix.suffixIfPotentialMatch("foo/bar/baz"), std::optional { "baz" }); } -TEST(SearchPathElem, suffixIfPotentialMatch_trailingSlash) { - SearchPath::Prefix prefix { .s = "foo" }; +TEST(LookupPathElem, suffixIfPotentialMatch_trailingSlash) { + LookupPath::Prefix prefix { .s = "foo" }; ASSERT_EQ(prefix.suffixIfPotentialMatch("foo/"), std::optional { "" }); } -TEST(SearchPathElem, suffixIfPotentialMatch_trailingDoubleSlash) { - SearchPath::Prefix prefix { .s = "foo" }; +TEST(LookupPathElem, suffixIfPotentialMatch_trailingDoubleSlash) { + LookupPath::Prefix prefix { .s = "foo" }; ASSERT_EQ(prefix.suffixIfPotentialMatch("foo//"), std::optional { "/" }); } -TEST(SearchPathElem, suffixIfPotentialMatch_trailingPath) { - SearchPath::Prefix prefix { .s = "foo" }; +TEST(LookupPathElem, suffixIfPotentialMatch_trailingPath) { + LookupPath::Prefix prefix { .s = "foo" }; ASSERT_EQ(prefix.suffixIfPotentialMatch("foo/bar/baz"), std::optional { "bar/baz" }); }