diff options
Diffstat (limited to 'third_party/nix/src/nix')
-rw-r--r-- | third_party/nix/src/nix/add-to-store.cc | 8 | ||||
-rw-r--r-- | third_party/nix/src/nix/build.cc | 8 | ||||
-rw-r--r-- | third_party/nix/src/nix/command.cc | 8 | ||||
-rw-r--r-- | third_party/nix/src/nix/command.hh | 4 | ||||
-rw-r--r-- | third_party/nix/src/nix/hash.cc | 4 | ||||
-rw-r--r-- | third_party/nix/src/nix/installables.cc | 12 | ||||
-rw-r--r-- | third_party/nix/src/nix/log.cc | 8 | ||||
-rw-r--r-- | third_party/nix/src/nix/main.cc | 24 | ||||
-rw-r--r-- | third_party/nix/src/nix/path-info.cc | 16 | ||||
-rw-r--r-- | third_party/nix/src/nix/repl.cc | 56 | ||||
-rw-r--r-- | third_party/nix/src/nix/run.cc | 24 | ||||
-rw-r--r-- | third_party/nix/src/nix/search.cc | 4 | ||||
-rw-r--r-- | third_party/nix/src/nix/show-derivation.cc | 4 | ||||
-rw-r--r-- | third_party/nix/src/nix/sigs.cc | 4 | ||||
-rw-r--r-- | third_party/nix/src/nix/upgrade-nix.cc | 4 | ||||
-rw-r--r-- | third_party/nix/src/nix/verify.cc | 12 | ||||
-rw-r--r-- | third_party/nix/src/nix/why-depends.cc | 16 |
17 files changed, 162 insertions, 54 deletions
diff --git a/third_party/nix/src/nix/add-to-store.cc b/third_party/nix/src/nix/add-to-store.cc index cc85cc02ea6e..b7fda9c9d390 100644 --- a/third_party/nix/src/nix/add-to-store.cc +++ b/third_party/nix/src/nix/add-to-store.cc @@ -27,7 +27,9 @@ struct CmdAddToStore : MixDryRun, StoreCommand { Examples examples() override { return {}; } void run(ref<Store> store) override { - if (!namePart) namePart = baseNameOf(path); + if (!namePart) { + namePart = baseNameOf(path); + } StringSink sink; dumpPath(path, sink); @@ -38,7 +40,9 @@ struct CmdAddToStore : MixDryRun, StoreCommand { info.path = store->makeFixedOutputPath(true, info.narHash, *namePart); info.ca = makeFixedOutputCA(true, info.narHash); - if (!dryRun) store->addToStore(info, sink.s); + if (!dryRun) { + store->addToStore(info, sink.s); + } std::cout << fmt("%s\n", info.path); } diff --git a/third_party/nix/src/nix/build.cc b/third_party/nix/src/nix/build.cc index 41d8e6f0d075..806be2b37ab4 100644 --- a/third_party/nix/src/nix/build.cc +++ b/third_party/nix/src/nix/build.cc @@ -51,8 +51,12 @@ struct CmdBuild : MixDryRun, InstallablesCommand { for (auto& output : b.outputs) if (auto store2 = store.dynamic_pointer_cast<LocalFSStore>()) { std::string symlink = outLink; - if (i) symlink += fmt("-%d", i); - if (output.first != "out") symlink += fmt("-%s", output.first); + if (i) { + symlink += fmt("-%d", i); + } + if (output.first != "out") { + symlink += fmt("-%s", output.first); + } store2->addPermRoot(output.second, absPath(symlink), true); } } diff --git a/third_party/nix/src/nix/command.cc b/third_party/nix/src/nix/command.cc index cf109c441612..1825bb6136be 100644 --- a/third_party/nix/src/nix/command.cc +++ b/third_party/nix/src/nix/command.cc @@ -62,8 +62,12 @@ void MultiCommand::printHelp(const string& programName, std::ostream& out) { } bool MultiCommand::processFlag(Strings::iterator& pos, Strings::iterator end) { - if (Args::processFlag(pos, end)) return true; - if (command && command->processFlag(pos, end)) return true; + if (Args::processFlag(pos, end)) { + return true; + } + if (command && command->processFlag(pos, end)) { + return true; + } return false; } diff --git a/third_party/nix/src/nix/command.hh b/third_party/nix/src/nix/command.hh index cc82c4b1aadd..a86f4782133f 100644 --- a/third_party/nix/src/nix/command.hh +++ b/third_party/nix/src/nix/command.hh @@ -163,7 +163,9 @@ struct RegisterCommand { static Commands* commands; RegisterCommand(ref<Command> command) { - if (!commands) commands = new Commands; + if (!commands) { + commands = new Commands; + } commands->emplace(command->name(), command); } }; diff --git a/third_party/nix/src/nix/hash.cc b/third_party/nix/src/nix/hash.cc index e3278ea77a59..77be77cfcdc0 100644 --- a/third_party/nix/src/nix/hash.cc +++ b/third_party/nix/src/nix/hash.cc @@ -36,7 +36,9 @@ struct CmdHash : Command { void run() override { for (auto path : paths) { Hash h = mode == mFile ? hashFile(ht, path) : hashPath(ht, path).first; - if (truncate && h.hashSize > 20) h = compressHash(h, 20); + if (truncate && h.hashSize > 20) { + h = compressHash(h, 20); + } std::cout << format("%1%\n") % h.to_string(base, base == SRI); } } diff --git a/third_party/nix/src/nix/installables.cc b/third_party/nix/src/nix/installables.cc index 2378a4b16a52..7ba916f4a6a2 100644 --- a/third_party/nix/src/nix/installables.cc +++ b/third_party/nix/src/nix/installables.cc @@ -45,8 +45,12 @@ Value* SourceExprCommand::getSourceExpr(EvalState& state) { std::unordered_set<std::string> seen; auto addEntry = [&](const std::string& name) { - if (name == "") return; - if (!seen.insert(name).second) return; + if (name == "") { + return; + } + if (!seen.insert(name).second) { + return; + } Value* v1 = state.allocValue(); mkPrimOpApp(*v1, state.getBuiltin("findFile"), state.getBuiltin("nixPath")); @@ -189,7 +193,9 @@ static std::vector<std::shared_ptr<Installable>> parseInstallables( std::vector<std::shared_ptr<Installable>> result; if (ss.empty() && useDefaultInstallables) { - if (cmd.file == "") cmd.file = "."; + if (cmd.file == "") { + cmd.file = "."; + } ss = {""}; } diff --git a/third_party/nix/src/nix/log.cc b/third_party/nix/src/nix/log.cc index 0a10924cad7b..29107bbdcdff 100644 --- a/third_party/nix/src/nix/log.cc +++ b/third_party/nix/src/nix/log.cc @@ -42,10 +42,14 @@ struct CmdLog : InstallableCommand { for (auto& sub : subs) { auto log = b.drvPath != "" ? sub->getBuildLog(b.drvPath) : nullptr; for (auto& output : b.outputs) { - if (log) break; + if (log) { + break; + } log = sub->getBuildLog(output.second); } - if (!log) continue; + if (!log) { + continue; + } LOG(INFO) << "got build log for '" << installable->what() << "' from '" << sub->getUri() << "'"; std::cout << *log; diff --git a/third_party/nix/src/nix/main.cc b/third_party/nix/src/nix/main.cc index 6e4db63cce0a..9dbe9b155bf2 100644 --- a/third_party/nix/src/nix/main.cc +++ b/third_party/nix/src/nix/main.cc @@ -27,12 +27,16 @@ namespace nix { static bool haveInternet() { struct ifaddrs* addrs; - if (getifaddrs(&addrs)) return true; + if (getifaddrs(&addrs)) { + return true; + } Finally free([&]() { freeifaddrs(addrs); }); for (auto i = addrs; i; i = i->ifa_next) { - if (!i->ifa_addr) continue; + if (!i->ifa_addr) { + continue; + } if (i->ifa_addr->sa_family == AF_INET) { if (ntohl(((sockaddr_in*)i->ifa_addr)->sin_addr.s_addr) != INADDR_LOOPBACK) { @@ -127,7 +131,9 @@ void mainWrapped(int argc, char** argv) { { auto legacy = (*RegisterLegacyCommand::commands)[programName]; - if (legacy) return legacy(argc, argv); + if (legacy) { + return legacy(argc, argv); + } } settings.verboseBuild = false; @@ -138,7 +144,9 @@ void mainWrapped(int argc, char** argv) { initPlugins(); - if (!args.command) args.showHelpAndExit(); + if (!args.command) { + args.showHelpAndExit(); + } if (args.useNet && !haveInternet()) { LOG(WARNING) << "you don't have Internet access; " @@ -148,10 +156,14 @@ void mainWrapped(int argc, char** argv) { if (!args.useNet) { // FIXME: should check for command line overrides only. - if (!settings.useSubstitutes.overriden) settings.useSubstitutes = false; + if (!settings.useSubstitutes.overriden) { + settings.useSubstitutes = false; + } if (!settings.tarballTtl.overriden) settings.tarballTtl = std::numeric_limits<unsigned int>::max(); - if (!downloadSettings.tries.overriden) downloadSettings.tries = 0; + if (!downloadSettings.tries.overriden) { + downloadSettings.tries = 0; + } if (!downloadSettings.connectTimeout.overriden) downloadSettings.connectTimeout = 1; } diff --git a/third_party/nix/src/nix/path-info.cc b/third_party/nix/src/nix/path-info.cc index 31f2897a81c8..4920a8c4d792 100644 --- a/third_party/nix/src/nix/path-info.cc +++ b/third_party/nix/src/nix/path-info.cc @@ -97,15 +97,23 @@ struct CmdPathInfo : StorePathsCommand, MixJSON { std::cout << std::string( std::max(0, (int)pathLen - (int)storePath.size()), ' '); - if (showSize) printSize(info->narSize); + if (showSize) { + printSize(info->narSize); + } - if (showClosureSize) printSize(store->getClosureSize(storePath).first); + if (showClosureSize) { + printSize(store->getClosureSize(storePath).first); + } if (showSigs) { std::cout << '\t'; Strings ss; - if (info->ultimate) ss.push_back("ultimate"); - if (info->ca != "") ss.push_back("ca:" + info->ca); + if (info->ultimate) { + ss.push_back("ultimate"); + } + if (info->ca != "") { + ss.push_back("ca:" + info->ca); + } for (auto& sig : info->sigs) ss.push_back(sig); std::cout << concatStringsSep(" ", ss); } diff --git a/third_party/nix/src/nix/repl.cc b/third_party/nix/src/nix/repl.cc index 2d7188740515..0297cca84854 100644 --- a/third_party/nix/src/nix/repl.cc +++ b/third_party/nix/src/nix/repl.cc @@ -123,7 +123,9 @@ void printHelp() { string removeWhitespace(string s) { s = chomp(s); size_t n = s.find_first_not_of(" \n\r\t"); - if (n != string::npos) s = string(s, n); + if (n != string::npos) { + s = string(s, n); + } return s; } @@ -143,13 +145,17 @@ static char* completionCallback(char* s, int* match) { if (possible.size() == 1) { *match = 1; auto* res = strdup(possible.begin()->c_str() + strlen(s)); - if (!res) throw Error("allocation failure"); + if (!res) { + throw Error("allocation failure"); + } return res; } else if (possible.size() > 1) { auto checkAllHaveSameAt = [&](size_t pos) { auto& first = *possible.begin(); for (auto& p : possible) { - if (p.size() <= pos || p[pos] != first[pos]) return false; + if (p.size() <= pos || p[pos] != first[pos]) { + return false; + } } return true; }; @@ -161,7 +167,9 @@ static char* completionCallback(char* s, int* match) { if (len > 0) { *match = 1; auto* res = strdup(std::string(*possible.begin(), start, len).c_str()); - if (!res) throw Error("allocation failure"); + if (!res) { + throw Error("allocation failure"); + } return res; } } @@ -216,7 +224,9 @@ void NixRepl::mainLoop(const std::vector<std::string>& files) { for (auto& i : files) loadedFiles.push_back(i); reloadFiles(); - if (!loadedFiles.empty()) std::cout << std::endl; + if (!loadedFiles.empty()) { + std::cout << std::endl; + } // Allow nix-repl specific settings in .inputrc rl_readline_name = "nix-repl"; @@ -236,10 +246,14 @@ void NixRepl::mainLoop(const std::vector<std::string>& files) { while (true) { // When continuing input from previous lines, don't print a prompt, just // align to the same number of chars as the prompt. - if (!getLine(input, input.empty() ? "nix-repl> " : " ")) break; + if (!getLine(input, input.empty() ? "nix-repl> " : " ")) { + break; + } try { - if (!removeWhitespace(input).empty() && !processLine(input)) return; + if (!removeWhitespace(input).empty() && !processLine(input)) { + return; + } } catch (ParseError& e) { if (e.msg().find("unexpected $end") != std::string::npos) { // For parse errors on incomplete input, we continue waiting for the @@ -334,7 +348,9 @@ StringSet NixRepl::completePrefix(string prefix) { /* This is a variable name; look it up in the current scope. */ StringSet::iterator i = varNames.lower_bound(cur); while (i != varNames.end()) { - if (string(*i, 0, cur.size()) != cur) break; + if (string(*i, 0, cur.size()) != cur) { + break; + } completions.insert(prev + *i); i++; } @@ -353,7 +369,9 @@ StringSet NixRepl::completePrefix(string prefix) { for (auto& i : *v.attrs) { string name = i.name; - if (string(name, 0, cur2.size()) != cur2) continue; + if (string(name, 0, cur2.size()) != cur2) { + continue; + } completions.insert(prev + expr + "." + name); } @@ -375,7 +393,9 @@ static int runProgram(const string& program, const Strings& args) { Pid pid; pid = fork(); - if (pid == -1) throw SysError("forking"); + if (pid == -1) { + throw SysError("forking"); + } if (pid == 0) { restoreAffinity(); execvp(program.c_str(), stringsToCharPtrs(args2).data()); @@ -386,7 +406,9 @@ static int runProgram(const string& program, const Strings& args) { } bool isVarName(const string& s) { - if (s.size() == 0) return false; + if (s.size() == 0) { + return false; + } char c = s[0]; if ((c >= '0' && c <= '9') || c == '-' || c == '\'') { return false; @@ -410,14 +432,18 @@ Path NixRepl::getDerivationPath(Value& v) { } bool NixRepl::processLine(string line) { - if (line == "") return true; + if (line == "") { + return true; + } string command, arg; if (line[0] == ':') { size_t p = line.find_first_of(" \n\r\t"); command = string(line, 0, p); - if (p != string::npos) arg = removeWhitespace(string(line, p)); + if (p != string::npos) { + arg = removeWhitespace(string(line, p)); + } } else { arg = line; } @@ -561,7 +587,9 @@ void NixRepl::reloadFiles() { bool first = true; for (auto& i : old) { - if (!first) std::cout << std::endl; + if (!first) { + std::cout << std::endl; + } first = false; std::cout << format("Loading '%1%'...") % i << std::endl; loadFile(i); diff --git a/third_party/nix/src/nix/run.cc b/third_party/nix/src/nix/run.cc index 0b5a2648f9fb..c246767ceddd 100644 --- a/third_party/nix/src/nix/run.cc +++ b/third_party/nix/src/nix/run.cc @@ -94,7 +94,9 @@ struct CmdRun : InstallablesCommand { std::map<std::string, std::string> kept; for (auto& var : keep) { auto s = getenv(var.c_str()); - if (s) kept[var] = s; + if (s) { + kept[var] = s; + } } clearEnv(); @@ -118,9 +120,13 @@ struct CmdRun : InstallablesCommand { while (!todo.empty()) { Path path = todo.front(); todo.pop(); - if (!done.insert(path).second) continue; + if (!done.insert(path).second) { + continue; + } - if (true) unixPath.push_front(path + "/bin"); + if (true) { + unixPath.push_front(path + "/bin"); + } auto propPath = path + "/nix-support/propagated-user-env-packages"; if (accessor->stat(propPath).type == FSAccessor::tRegular) { @@ -206,9 +212,13 @@ void chrootHelper(int argc, char** argv) { for (auto entry : readDirectory("/")) { auto src = "/" + entry.name; auto st = lstat(src); - if (!S_ISDIR(st.st_mode)) continue; + if (!S_ISDIR(st.st_mode)) { + continue; + } Path dst = tmpDir + "/" + entry.name; - if (pathExists(dst)) continue; + if (pathExists(dst)) { + continue; + } if (mkdir(dst.c_str(), 0700) == -1) throw SysError("creating directory '%s'", dst); if (mount(src.c_str(), dst.c_str(), "", MS_BIND | MS_REC, 0) == -1) @@ -216,7 +226,9 @@ void chrootHelper(int argc, char** argv) { } char* cwd = getcwd(0, 0); - if (!cwd) throw SysError("getting current directory"); + if (!cwd) { + throw SysError("getting current directory"); + } Finally freeCwd([&]() { free(cwd); }); if (chroot(tmpDir.c_str()) == -1) diff --git a/third_party/nix/src/nix/search.cc b/third_party/nix/src/nix/search.cc index b7cb586b0f4d..f44269eee5c1 100644 --- a/third_party/nix/src/nix/search.cc +++ b/third_party/nix/src/nix/search.cc @@ -244,7 +244,9 @@ struct CmdSearch : SourceExprCommand, MixJSON { /* Fun fact: catching std::ios::failure does not work due to C++11 ABI shenanigans. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66145 */ - if (!jsonCacheFile) throw Error("error writing to %s", tmpFile); + if (!jsonCacheFile) { + throw Error("error writing to %s", tmpFile); + } throw; } diff --git a/third_party/nix/src/nix/show-derivation.cc b/third_party/nix/src/nix/show-derivation.cc index 44e33cef4c98..c7722b6428b5 100644 --- a/third_party/nix/src/nix/show-derivation.cc +++ b/third_party/nix/src/nix/show-derivation.cc @@ -50,7 +50,9 @@ struct CmdShowDerivation : InstallablesCommand { JSONObject jsonRoot(std::cout, true); for (auto& drvPath : drvPaths) { - if (!isDerivation(drvPath)) continue; + if (!isDerivation(drvPath)) { + continue; + } auto drvObj(jsonRoot.object(drvPath)); diff --git a/third_party/nix/src/nix/sigs.cc b/third_party/nix/src/nix/sigs.cc index cc9d579909e2..d548f5445fe3 100644 --- a/third_party/nix/src/nix/sigs.cc +++ b/third_party/nix/src/nix/sigs.cc @@ -67,7 +67,9 @@ struct CmdCopySigs : StorePathsCommand { continue; for (auto& sig : info2->sigs) - if (!info->sigs.count(sig)) newSigs.insert(sig); + if (!info->sigs.count(sig)) { + newSigs.insert(sig); + } } catch (InvalidPath&) { } } diff --git a/third_party/nix/src/nix/upgrade-nix.cc b/third_party/nix/src/nix/upgrade-nix.cc index 49f8db3b5b5f..277d761ec581 100644 --- a/third_party/nix/src/nix/upgrade-nix.cc +++ b/third_party/nix/src/nix/upgrade-nix.cc @@ -52,7 +52,9 @@ struct CmdUpgradeNix : MixDryRun, StoreCommand { void run(ref<Store> store) override { evalSettings.pureEval = true; - if (profileDir == "") profileDir = getProfileDir(store); + if (profileDir == "") { + profileDir = getProfileDir(store); + } LOG(INFO) << "upgrading Nix in profile '" << profileDir << "'"; diff --git a/third_party/nix/src/nix/verify.cc b/third_party/nix/src/nix/verify.cc index 67128d866858..5cac3c9802a7 100644 --- a/third_party/nix/src/nix/verify.cc +++ b/third_party/nix/src/nix/verify.cc @@ -102,7 +102,9 @@ struct CmdVerify : StorePathsCommand { auto doSigs = [&](StringSet sigs) { for (auto sig : sigs) { - if (sigsSeen.count(sig)) continue; + if (sigsSeen.count(sig)) { + continue; + } sigsSeen.insert(sig); if (validSigs < ValidPathInfo::maxSigs && info->checkSignature(publicKeys, sig)) @@ -116,7 +118,9 @@ struct CmdVerify : StorePathsCommand { doSigs(info->sigs); for (auto& store2 : substituters) { - if (validSigs >= actualSigsNeeded) break; + if (validSigs >= actualSigsNeeded) { + break; + } try { auto info2 = store2->queryPathInfo(info->path); if (info2->isContentAddressed(*store)) @@ -128,7 +132,9 @@ struct CmdVerify : StorePathsCommand { } } - if (validSigs >= actualSigsNeeded) good = true; + if (validSigs >= actualSigsNeeded) { + good = true; + } } if (!good) { diff --git a/third_party/nix/src/nix/why-depends.cc b/third_party/nix/src/nix/why-depends.cc index 88e1e357f4b4..b0271d41992d 100644 --- a/third_party/nix/src/nix/why-depends.cc +++ b/third_party/nix/src/nix/why-depends.cc @@ -145,7 +145,9 @@ struct CmdWhyDepends : SourceExprCommand { if (node.path == dependencyPath && !all && packagePath != dependencyPath) throw BailOut(); - if (node.visited) return; + if (node.visited) { + return; + } node.visited = true; /* Sort the references by distance to `dependency` to @@ -154,9 +156,13 @@ struct CmdWhyDepends : SourceExprCommand { std::set<std::string> hashes; for (auto& ref : node.refs) { - if (ref == node.path && packagePath != dependencyPath) continue; + if (ref == node.path && packagePath != dependencyPath) { + continue; + } auto& node2 = graph.at(ref); - if (node2.dist == inf) continue; + if (node2.dist == inf) { + continue; + } refs.emplace(node2.dist, &node2); hashes.insert(storePathToHash(node2.path)); } @@ -228,7 +234,9 @@ struct CmdWhyDepends : SourceExprCommand { << (first ? (last ? treeLast : treeConn) : (last ? treeNull : treeLine)) << hit; - if (!all) break; + if (!all) { + break; + } } printNode(*ref.second, tailPad + (last ? treeNull : treeLine), |