diff --git a/src/nix/prefetch.cc b/src/nix/prefetch.cc index b67d381ca..9f2d6cc57 100644 --- a/src/nix/prefetch.cc +++ b/src/nix/prefetch.cc @@ -257,6 +257,7 @@ struct CmdStorePrefetchFile : StoreCommand, MixJSON { std::string url; bool executable = false; + bool unpack = false; std::optional name; HashType hashType = htSHA256; std::optional expectedHash; @@ -289,6 +290,14 @@ struct CmdStorePrefetchFile : StoreCommand, MixJSON .handler = {&executable, true}, }); + addFlag({ + .longName = "unpack", + .description = + "Unpack the archive (which must be a tarball or zip file) and add " + "the result to the Nix store.", + .handler = {&unpack, true}, + }); + expectArg("url", &url); } @@ -305,7 +314,7 @@ struct CmdStorePrefetchFile : StoreCommand, MixJSON } void run(ref store) override { - auto [storePath, hash] = prefetchFile(store, url, name, hashType, expectedHash, false, executable); + auto [storePath, hash] = prefetchFile(store, url, name, hashType, expectedHash, unpack, executable); if (json) { auto res = nlohmann::json::object();