From b6d794fb8df09b9b5d86f3fe2a2789631215f8b5 Mon Sep 17 00:00:00 2001 From: YI Date: Sun, 1 Mar 2020 16:11:22 +0800 Subject: [PATCH] display attr-path only when queried available --- doc/manual/command-ref/nix-env.xml | 3 ++- src/nix-env/nix-env.cc | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/manual/command-ref/nix-env.xml b/doc/manual/command-ref/nix-env.xml index d257a5e49..9c03ccce1 100644 --- a/doc/manual/command-ref/nix-env.xml +++ b/doc/manual/command-ref/nix-env.xml @@ -1066,7 +1066,8 @@ user environment elements, etc. --> the derivation, which can be used to unambiguously select it using the option available in commands that install derivations like - nix-env --install. + nix-env --install. This option only works + together with diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc index a40d0c7e6..106dfe0b6 100644 --- a/src/nix-env/nix-env.cc +++ b/src/nix-env/nix-env.cc @@ -914,6 +914,8 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs) throw UsageError(format("unknown flag '%1%'") % arg); } + if (printAttrPath && source != sAvailable) + throw UsageError("--attr-path(-P) only works with --available"); /* Obtain derivation information from the specified source. */ DrvInfos availElems, installedElems;