From 0f2cf531f705d370321843e5ba9135b2ebdb5d19 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Sun, 17 May 2020 16:31:57 +0100 Subject: style(3p/nix): Reformat project in Google C++ style Reformatted with: fd . -e hh -e cc | xargs clang-format -i --- third_party/nix/src/nix/show-derivation.cc | 166 +++++++++++++---------------- 1 file changed, 75 insertions(+), 91 deletions(-) (limited to 'third_party/nix/src/nix/show-derivation.cc') diff --git a/third_party/nix/src/nix/show-derivation.cc b/third_party/nix/src/nix/show-derivation.cc index ee94fded364f..44e33cef4c98 100644 --- a/third_party/nix/src/nix/show-derivation.cc +++ b/third_party/nix/src/nix/show-derivation.cc @@ -1,119 +1,103 @@ // FIXME: integrate this with nix path-info? +#include "archive.hh" #include "command.hh" #include "common-args.hh" -#include "store-api.hh" -#include "archive.hh" -#include "json.hh" #include "derivations.hh" +#include "json.hh" +#include "store-api.hh" using namespace nix; -struct CmdShowDerivation : InstallablesCommand -{ - bool recursive = false; - - CmdShowDerivation() - { - mkFlag() - .longName("recursive") - .shortName('r') - .description("include the dependencies of the specified derivations") - .set(&recursive, true); - } - - std::string name() override - { - return "show-derivation"; +struct CmdShowDerivation : InstallablesCommand { + bool recursive = false; + + CmdShowDerivation() { + mkFlag() + .longName("recursive") + .shortName('r') + .description("include the dependencies of the specified derivations") + .set(&recursive, true); + } + + std::string name() override { return "show-derivation"; } + + std::string description() override { + return "show the contents of a store derivation"; + } + + Examples examples() override { + return { + Example{"To show the store derivation that results from evaluating the " + "Hello package:", + "nix show-derivation nixpkgs.hello"}, + Example{"To show the full derivation graph (if available) that " + "produced your NixOS system:", + "nix show-derivation -r /run/current-system"}, + }; + } + + void run(ref store) override { + auto drvPaths = toDerivations(store, installables, true); + + if (recursive) { + PathSet closure; + store->computeFSClosure(drvPaths, closure); + drvPaths = closure; } - std::string description() override { - return "show the contents of a store derivation"; - } + JSONObject jsonRoot(std::cout, true); - Examples examples() override - { - return { - Example{ - "To show the store derivation that results from evaluating the Hello package:", - "nix show-derivation nixpkgs.hello" - }, - Example{ - "To show the full derivation graph (if available) that produced your NixOS system:", - "nix show-derivation -r /run/current-system" - }, - }; - } + for (auto& drvPath : drvPaths) { + if (!isDerivation(drvPath)) continue; - void run(ref store) override - { - auto drvPaths = toDerivations(store, installables, true); + auto drvObj(jsonRoot.object(drvPath)); - if (recursive) { - PathSet closure; - store->computeFSClosure(drvPaths, closure); - drvPaths = closure; - } + auto drv = readDerivation(drvPath); { - - JSONObject jsonRoot(std::cout, true); - - for (auto & drvPath : drvPaths) { - if (!isDerivation(drvPath)) continue; - - auto drvObj(jsonRoot.object(drvPath)); - - auto drv = readDerivation(drvPath); - - { - auto outputsObj(drvObj.object("outputs")); - for (auto & output : drv.outputs) { - auto outputObj(outputsObj.object(output.first)); - outputObj.attr("path", output.second.path); - if (output.second.hash != "") { - outputObj.attr("hashAlgo", output.second.hashAlgo); - outputObj.attr("hash", output.second.hash); - } - } - } - - { - auto inputsList(drvObj.list("inputSrcs")); - for (auto & input : drv.inputSrcs) - inputsList.elem(input); + auto outputsObj(drvObj.object("outputs")); + for (auto& output : drv.outputs) { + auto outputObj(outputsObj.object(output.first)); + outputObj.attr("path", output.second.path); + if (output.second.hash != "") { + outputObj.attr("hashAlgo", output.second.hashAlgo); + outputObj.attr("hash", output.second.hash); } + } + } - { - auto inputDrvsObj(drvObj.object("inputDrvs")); - for (auto & input : drv.inputDrvs) { - auto inputList(inputDrvsObj.list(input.first)); - for (auto & outputId : input.second) - inputList.elem(outputId); - } - } + { + auto inputsList(drvObj.list("inputSrcs")); + for (auto& input : drv.inputSrcs) inputsList.elem(input); + } - drvObj.attr("platform", drv.platform); - drvObj.attr("builder", drv.builder); + { + auto inputDrvsObj(drvObj.object("inputDrvs")); + for (auto& input : drv.inputDrvs) { + auto inputList(inputDrvsObj.list(input.first)); + for (auto& outputId : input.second) inputList.elem(outputId); + } + } - { - auto argsList(drvObj.list("args")); - for (auto & arg : drv.args) - argsList.elem(arg); - } + drvObj.attr("platform", drv.platform); + drvObj.attr("builder", drv.builder); - { - auto envObj(drvObj.object("env")); - for (auto & var : drv.env) - envObj.attr(var.first, var.second); - } + { + auto argsList(drvObj.list("args")); + for (auto& arg : drv.args) argsList.elem(arg); } + { + auto envObj(drvObj.object("env")); + for (auto& var : drv.env) envObj.attr(var.first, var.second); } - - std::cout << "\n"; + } } + + std::cout << "\n"; + } }; static RegisterCommand r1(make_ref()); -- cgit 1.4.1