about summary refs log tree commit diff
path: root/src/nix-env
diff options
context:
space:
mode:
Diffstat (limited to 'src/nix-env')
-rw-r--r--src/nix-env/help.txt2
-rw-r--r--src/nix-env/main.cc5
2 files changed, 7 insertions, 0 deletions
diff --git a/src/nix-env/help.txt b/src/nix-env/help.txt
index 3287bab28eae..a97df87576b3 100644
--- a/src/nix-env/help.txt
+++ b/src/nix-env/help.txt
@@ -48,6 +48,8 @@ Query types:
 
   --status / -s: print installed/present status
   --no-name: hide derivation names
+  --attr-path / -A: shows the unambiguous attribute name of the
+      derivation which can be used when installing with -A
   --system: print the platform type of the derivation 
   --compare-versions / -c: compare version to available or installed
   --drv-path: print path of derivation
diff --git a/src/nix-env/main.cc b/src/nix-env/main.cc
index 633c85b618f7..875cdd7447e8 100644
--- a/src/nix-env/main.cc
+++ b/src/nix-env/main.cc
@@ -724,6 +724,7 @@ static void opQuery(Globals & globals,
 {
     bool printStatus = false;
     bool printName = true;
+    bool printAttrPath = false;
     bool printSystem = false;
     bool printDrvPath = false;
     bool printOutPath = false;
@@ -747,6 +748,8 @@ static void opQuery(Globals & globals,
         else if (*i == "--available" || *i == "-a") source = sAvailable;
         else throw UsageError(format("unknown flag `%1%'") % *i);
 
+    if (globals.instSource.type == srcAttrPath) printAttrPath = true; /* hack */
+
     if (opArgs.size() == 0) {
         printMsg(lvlInfo, "warning: you probably meant to specify the argument '*' to show all packages");
     }
@@ -809,6 +812,8 @@ static void opQuery(Globals & globals,
                     + (subs.size() > 0 ? "S" : "-"));
             }
 
+            if (printAttrPath) columns.push_back(i->attrPath);
+
             if (printName) columns.push_back(i->name);
 
             if (compareVersions) {