forked from lix-project/lix
nix-store: make --dump-db take a list of paths to dump
Inside a derivation, exportReferencesGraph already provides a way to dump the Nix database for a specific closure. On the command line, --dump-db gave us the same information, but only for the entire Nix database at once. With this change, one can now pass a list of paths to --dump-db to get the Nix database dumped for just those paths. (The user is responsible for ensuring this is a closure, like for --export). Among other things, this is useful for deploying a closure to a new host without using --import/--export; one can use tar to transfer the store paths, and --dump-db/--load-db to transfer the validity information. This is useful if the new host doesn't actually have Nix yet, and the closure that is being deployed itself contains Nix.
This commit is contained in:
parent
92d08c02c8
commit
5f1891b795
|
@ -1282,6 +1282,7 @@ ktorrent-2.2.1/NEWS
|
||||||
<cmdsynopsis>
|
<cmdsynopsis>
|
||||||
<command>nix-store</command>
|
<command>nix-store</command>
|
||||||
<arg choice='plain'><option>--dump-db</option></arg>
|
<arg choice='plain'><option>--dump-db</option></arg>
|
||||||
|
<arg rep='repeat'><replaceable>paths</replaceable></arg>
|
||||||
</cmdsynopsis>
|
</cmdsynopsis>
|
||||||
</refsection>
|
</refsection>
|
||||||
|
|
||||||
|
@ -1292,6 +1293,13 @@ Nix database to standard output. It can be loaded into an empty Nix
|
||||||
store using <option>--load-db</option>. This is useful for making
|
store using <option>--load-db</option>. This is useful for making
|
||||||
backups and when migrating to different database schemas.</para>
|
backups and when migrating to different database schemas.</para>
|
||||||
|
|
||||||
|
<para>By default, <option>--dump-db</option> will dump the entire Nix
|
||||||
|
database. When one or more store paths is passed, only the subset of
|
||||||
|
the Nix database for those store paths is dumped. As with
|
||||||
|
<option>--export</option>, the user is responsible for passing all the
|
||||||
|
store paths for a closure. See <option>--export</option> for an
|
||||||
|
example.</para>
|
||||||
|
|
||||||
</refsection>
|
</refsection>
|
||||||
|
|
||||||
</refsection>
|
</refsection>
|
||||||
|
|
|
@ -485,12 +485,17 @@ static void opReadLog(Strings opFlags, Strings opArgs)
|
||||||
static void opDumpDB(Strings opFlags, Strings opArgs)
|
static void opDumpDB(Strings opFlags, Strings opArgs)
|
||||||
{
|
{
|
||||||
if (!opFlags.empty()) throw UsageError("unknown flag");
|
if (!opFlags.empty()) throw UsageError("unknown flag");
|
||||||
if (!opArgs.empty())
|
if (!opArgs.empty()) {
|
||||||
throw UsageError("no arguments expected");
|
for (auto & i : opArgs)
|
||||||
|
i = store->followLinksToStorePath(i);
|
||||||
|
for (auto & i : opArgs)
|
||||||
|
cout << store->makeValidityRegistration({i}, true, true);
|
||||||
|
} else {
|
||||||
PathSet validPaths = store->queryAllValidPaths();
|
PathSet validPaths = store->queryAllValidPaths();
|
||||||
for (auto & i : validPaths)
|
for (auto & i : validPaths)
|
||||||
cout << store->makeValidityRegistration({i}, true, true);
|
cout << store->makeValidityRegistration({i}, true, true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void registerValidity(bool reregister, bool hashGiven, bool canonicalise)
|
static void registerValidity(bool reregister, bool hashGiven, bool canonicalise)
|
||||||
|
|
Loading…
Reference in a new issue