From d7a9e5346ce61876658c840acc22768bcfc882f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophane=20Hufschmitt?= Date: Mon, 12 Jun 2023 08:52:24 +0200 Subject: [PATCH] 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. --- src/nix/flake.cc | 3 +++ src/nix/search.cc | 1 + 2 files changed, 4 insertions(+) diff --git a/src/nix/flake.cc b/src/nix/flake.cc index 1eea52e15..6d225043f 100644 --- a/src/nix/flake.cc +++ b/src/nix/flake.cc @@ -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 pager = json ? std::nullopt : std::optional(RunPager()); try { auto recurse = [&]() { diff --git a/src/nix/search.cc b/src/nix/search.cc index c92ed1663..cc437c9cb 100644 --- a/src/nix/search.cc +++ b/src/nix/search.cc @@ -63,6 +63,7 @@ struct CmdSearch : InstallableValueCommand, MixJSON void run(ref store, ref installable) override { + RunPager pager; settings.readOnlyMode = true; evalSettings.enableImportFromDerivation.setDefault(false);