1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-12-16 22:11:05 +01:00

Redirect some Nix command outputs to a pager

Make `nix search`, `nix flake show` and `nix flake metadata` pipe their
output into a pager to make their result easier to visualise.
This commit is contained in:
Théophane Hufschmitt 2023-06-12 08:52:24 +02:00
parent 9c6ede85fc
commit d7a9e5346c
2 changed files with 4 additions and 0 deletions

View file

@ -167,6 +167,8 @@ struct CmdFlakeMetadata : FlakeCommand, MixJSON
auto lockedFlake = lockFlake();
auto & flake = lockedFlake.flake;
RunPager pager;
if (json) {
nlohmann::json j;
if (flake.description)
@ -1128,6 +1130,7 @@ struct CmdFlakeShow : FlakeCommand, MixJSON
Activity act(*logger, lvlInfo, actUnknown,
fmt("evaluating '%s'", concatStringsSep(".", attrPathS)));
std::optional<RunPager> pager = json ? std::nullopt : std::optional<RunPager>(RunPager());
try {
auto recurse = [&]()
{

View file

@ -63,6 +63,7 @@ struct CmdSearch : InstallableValueCommand, MixJSON
void run(ref<Store> store, ref<InstallableValue> installable) override
{
RunPager pager;
settings.readOnlyMode = true;
evalSettings.enableImportFromDerivation.setDefault(false);