diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2022-01-17 19:45:21 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2022-01-18 14:08:49 +0100 |
commit | 4dda1f92aae05dd9d633152458d65a3815bcd03c (patch) | |
tree | 84260b953cb80933b0a10a6db52dd2c9dfde5668 /src/nix/store-copy-log.cc | |
parent | 6448ea84ab537600d3f350867063bc305b3bb910 (diff) |
Add command 'nix store copy-log'
Fixes #5222.
Diffstat (limited to 'src/nix/store-copy-log.cc')
-rw-r--r-- | src/nix/store-copy-log.cc | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/nix/store-copy-log.cc b/src/nix/store-copy-log.cc new file mode 100644 index 000000000..fa6436cd0 --- /dev/null +++ b/src/nix/store-copy-log.cc @@ -0,0 +1,40 @@ +#include "command.hh" +#include "shared.hh" +#include "store-api.hh" +#include "sync.hh" +#include "thread-pool.hh" + +#include <atomic> + +using namespace nix; + +struct CmdCopyLog : virtual CopyCommand, virtual InstallablesCommand +{ + std::string description() override + { + return "copy build logs between Nix stores"; + } + + std::string doc() override + { + return + #include "store-copy-log.md" + ; + } + + Category category() override { return catUtility; } + + void run(ref<Store> srcStore) override + { + auto dstStore = getDstStore(); + + for (auto & path : toDerivations(srcStore, installables, true)) { + if (auto log = srcStore->getBuildLog(path)) + dstStore->addBuildLog(path, *log); + else + throw Error("build log for '%s' is not available", srcStore->printStorePath(path)); + } + } +}; + +static auto rCmdCopyLog = registerCommand2<CmdCopyLog>({"store", "copy-log"}); |