1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-07 06:01:48 +02:00

Move most store-related commands to 'nix store'

This commit is contained in:
Eelco Dolstra 2020-07-24 20:38:56 +02:00
parent a1cd805cba
commit ea2062a2d9
17 changed files with 62 additions and 77 deletions

View file

@ -43,8 +43,6 @@ struct CmdAddToStore : MixDryRun, StoreCommand
;
}
Category category() override { return catUtility; }
void run(ref<Store> store) override
{
if (!namePart) namePart = baseNameOf(path);
@ -80,4 +78,4 @@ struct CmdAddToStore : MixDryRun, StoreCommand
}
};
static auto rCmdAddToStore = registerCommand<CmdAddToStore>("add-to-store");
static auto rCmdAddToStore = registerCommand2<CmdAddToStore>({"store", "add-path"});

View file

@ -37,8 +37,6 @@ struct CmdCatStore : StoreCommand, MixCat
return "print the contents of a file in the Nix store on stdout";
}
Category category() override { return catUtility; }
void run(ref<Store> store) override
{
cat(store->getFSAccessor());

View file

@ -121,14 +121,12 @@ struct CmdDiffClosures : SourceExprCommand
return "show what packages and versions were added and removed between two closures";
}
Category category() override { return catSecondary; }
Examples examples() override
{
return {
{
"To show what got added and removed between two versions of the NixOS system profile:",
"nix diff-closures /nix/var/nix/profiles/system-655-link /nix/var/nix/profiles/system-658-link",
"nix store diff-closures /nix/var/nix/profiles/system-655-link /nix/var/nix/profiles/system-658-link",
},
};
}
@ -143,4 +141,4 @@ struct CmdDiffClosures : SourceExprCommand
}
};
static auto rCmdDiffClosures = registerCommand<CmdDiffClosures>("diff-closures");
static auto rCmdDiffClosures = registerCommand2<CmdDiffClosures>({"store", "diff-closures"});

View file

@ -16,13 +16,11 @@ struct CmdDumpPath : StorePathCommand
return {
Example{
"To get a NAR from the binary cache https://cache.nixos.org/:",
"nix dump-path --store https://cache.nixos.org/ /nix/store/7crrmih8c52r8fbnqb933dxrsp44md93-glibc-2.25"
"nix store dump-path --store https://cache.nixos.org/ /nix/store/7crrmih8c52r8fbnqb933dxrsp44md93-glibc-2.25"
},
};
}
Category category() override { return catUtility; }
void run(ref<Store> store, const StorePath & storePath) override
{
FdSink sink(STDOUT_FILENO);
@ -31,7 +29,6 @@ struct CmdDumpPath : StorePathCommand
}
};
static auto rDumpPath = registerCommand2<CmdDumpPath>({"store", "dump-path"});
struct CmdDumpPath2 : Command

View file

@ -97,7 +97,7 @@ struct CmdLsStore : StoreCommand, MixLs
return {
Example{
"To list the contents of a store path in a binary cache:",
"nix ls-store --store https://cache.nixos.org/ -lR /nix/store/0i2jd68mp5g6h2sa5k9c85rb80sn8hi9-hello-2.10"
"nix store ls --store https://cache.nixos.org/ -lR /nix/store/0i2jd68mp5g6h2sa5k9c85rb80sn8hi9-hello-2.10"
},
};
}
@ -107,8 +107,6 @@ struct CmdLsStore : StoreCommand, MixLs
return "show information about a path in the Nix store";
}
Category category() override { return catUtility; }
void run(ref<Store> store) override
{
list(store->getFSAccessor());

View file

@ -115,17 +115,25 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs
}
std::map<std::string, std::vector<std::string>> aliases = {
{"add-to-store", {"store", "add-path"}},
{"cat-nar", {"nar", "cat"}},
{"cat-store", {"store", "cat"}},
{"copy-sigs", {"store", "copy-sigs"}},
{"dev-shell", {"develop"}},
{"diff-closures", {"store", "diff-closures"}},
{"dump-path", {"store", "dump-path"}},
{"hash-file", {"hash", "file"}},
{"hash-path", {"hash", "path"}},
{"ls-nar", {"nar", "ls"}},
{"ls-store", {"store", "ls"}},
{"make-content-addressable", {"store", "make-content-addressable"}},
{"optimise-store", {"store", "optimise"}},
{"ping-store", {"store", "ping"}},
{"sign-paths", {"store", "sign-paths"}},
{"to-base16", {"hash", "to-base16"}},
{"to-base32", {"hash", "to-base32"}},
{"to-base64", {"hash", "to-base64"}},
{"ls-nar", {"nar", "ls"}},
{"ls-store", {"store", "ls"}},
{"cat-nar", {"nar", "cat"}},
{"cat-store", {"store", "cat"}},
{"dump-path", {"store", "dump-path"}},
{"verify", {"store", "verify"}},
};
bool aliasUsed = false;

View file

@ -23,17 +23,15 @@ struct CmdMakeContentAddressable : StorePathsCommand, MixJSON
return {
Example{
"To create a content-addressable representation of GNU Hello (but not its dependencies):",
"nix make-content-addressable nixpkgs#hello"
"nix store make-content-addressable nixpkgs#hello"
},
Example{
"To compute a content-addressable representation of the current NixOS system closure:",
"nix make-content-addressable -r /run/current-system"
"nix store make-content-addressable -r /run/current-system"
},
};
}
Category category() override { return catUtility; }
void run(ref<Store> store, StorePaths storePaths) override
{
auto paths = store->topoSortPaths(StorePathSet(storePaths.begin(), storePaths.end()));
@ -108,4 +106,4 @@ struct CmdMakeContentAddressable : StorePathsCommand, MixJSON
}
};
static auto rCmdMakeContentAddressable = registerCommand<CmdMakeContentAddressable>("make-content-addressable");
static auto rCmdMakeContentAddressable = registerCommand2<CmdMakeContentAddressable>({"store", "make-content-addressable"});

View file

@ -18,17 +18,15 @@ struct CmdOptimiseStore : StoreCommand
return {
Example{
"To optimise the Nix store:",
"nix optimise-store"
"nix store optimise"
},
};
}
Category category() override { return catUtility; }
void run(ref<Store> store) override
{
store->optimiseStore();
}
};
static auto rCmdOptimiseStore = registerCommand<CmdOptimiseStore>("optimise-store");
static auto rCmdOptimiseStore = registerCommand2<CmdOptimiseStore>({"store", "optimise"});

View file

@ -16,17 +16,15 @@ struct CmdPingStore : StoreCommand
return {
Example{
"To test whether connecting to a remote Nix store via SSH works:",
"nix ping-store --store ssh://mac1"
"nix store ping --store ssh://mac1"
},
};
}
Category category() override { return catUtility; }
void run(ref<Store> store) override
{
store->connect();
}
};
static auto rCmdPingStore = registerCommand<CmdPingStore>("ping-store");
static auto rCmdPingStore = registerCommand2<CmdPingStore>({"store", "ping"});

View file

@ -27,8 +27,6 @@ struct CmdCopySigs : StorePathsCommand
return "copy path signatures from substituters (like binary caches)";
}
Category category() override { return catUtility; }
void run(ref<Store> store, StorePaths storePaths) override
{
if (substituterUris.empty())
@ -92,7 +90,7 @@ struct CmdCopySigs : StorePathsCommand
}
};
static auto rCmdCopySigs = registerCommand<CmdCopySigs>("copy-sigs");
static auto rCmdCopySigs = registerCommand2<CmdCopySigs>({"store", "copy-sigs"});
struct CmdSignPaths : StorePathsCommand
{
@ -115,8 +113,6 @@ struct CmdSignPaths : StorePathsCommand
return "sign the specified paths";
}
Category category() override { return catUtility; }
void run(ref<Store> store, StorePaths storePaths) override
{
if (secretKeyFile.empty())
@ -144,4 +140,4 @@ struct CmdSignPaths : StorePathsCommand
}
};
static auto rCmdSignPaths = registerCommand<CmdSignPaths>("sign-paths");
static auto rCmdSignPaths = registerCommand2<CmdSignPaths>({"store", "sign-paths"});

View file

@ -40,17 +40,15 @@ struct CmdVerify : StorePathsCommand
return {
Example{
"To verify the entire Nix store:",
"nix verify --all"
"nix store verify --all"
},
Example{
"To check whether each path in the closure of Firefox has at least 2 signatures:",
"nix verify -r -n2 --no-contents $(type -p firefox)"
"nix store verify -r -n2 --no-contents $(type -p firefox)"
},
};
}
Category category() override { return catSecondary; }
void run(ref<Store> store, StorePaths storePaths) override
{
std::vector<ref<Store>> substituters;
@ -189,4 +187,4 @@ struct CmdVerify : StorePathsCommand
}
};
static auto rCmdVerify = registerCommand<CmdVerify>("verify");
static auto rCmdVerify = registerCommand2<CmdVerify>({"store", "verify"});