1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-01 12:37:59 +02:00

Added utility command ‘nix-instantiate --find-file’ to look up a file in Nix's search path

This commit is contained in:
Eelco Dolstra 2012-04-17 17:14:14 +02:00
parent 8cf1719e3e
commit 8745fade03
2 changed files with 26 additions and 0 deletions

View file

@ -79,6 +79,7 @@ void run(Strings args)
EvalState state;
Strings files;
bool readStdin = false;
bool findFile = false;
bool evalOnly = false;
bool parseOnly = false;
bool xmlOutput = false;
@ -100,6 +101,8 @@ void run(Strings args)
readOnlyMode = true;
parseOnly = evalOnly = true;
}
else if (arg == "--find-file")
findFile = true;
else if (arg == "--attr" || arg == "-A") {
if (i == args.end())
throw UsageError("`--attr' requires an argument");
@ -130,6 +133,15 @@ void run(Strings args)
if (attrPaths.empty()) attrPaths.push_back("");
if (findFile) {
foreach (Strings::iterator, i, files) {
Path p = state.findFile(*i);
if (p == "") throw Error(format("unable to find `%1%'") % *i);
std::cout << p << std::endl;
}
return;
}
store = openStore();
if (readStdin) {