From 52b7357a1b2ea287448b4035e14d92a2b29711fb Mon Sep 17 00:00:00 2001 From: Matthieu Coudron <886074+teto@users.noreply.github.com> Date: Sun, 27 Aug 2023 00:29:05 +0200 Subject: [PATCH] nix flake show: name attribute that must be a derivation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I would run `nix flake show` on a flake than hit: === ├───ihaskell: package 'ihaskell-wrapper' ├───ihaskell-96: package 'ihaskell-wrapper' ├───ihaskell-96-dev: package 'ghc-shell-for-ihaskell-0.10.4.0' error: expected a derivation === and it is not obvious what package is the culprit here since nix stops rightaway. --- src/nix/flake.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/nix/flake.cc b/src/nix/flake.cc index 3d174dc53..cef674eb5 100644 --- a/src/nix/flake.cc +++ b/src/nix/flake.cc @@ -1332,8 +1332,10 @@ struct CmdFlakeShow : FlakeCommand, MixJSON try { if (visitor.isDerivation()) showDerivation(); - else - throw Error("expected a derivation"); + else { + auto name = visitor.getAttrPathStr(state->sName); + logger->warn(fmt("%s must be a derivation", name)); + } } catch (IFDError & e) { if (!json) { logger->cout(fmt("%s " ANSI_WARNING "omitted due to use of import from derivation" ANSI_NORMAL, headerPrefix));