about summary refs log tree commit diff
path: root/src/libexpr/common-opts.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2011-12-01T16·41+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2011-12-01T16·41+0000
commitb12b21825c949ef9b9327c6a0c9e2d5601aaf0b2 (patch)
treead58ff48bd39e25f3ea67c96a00a510b40fb7a77 /src/libexpr/common-opts.cc
parent23c38a04ccba4469b9aa98167532c236beeee0a0 (diff)
* Allow '<nixexpr>' syntax to be used in nix-instantiate, nix-build
  and nix-env, e.g.,

  $ nix-env -f '<nixpkgs>' -i patchelf

  or

  $ nix-build '<nixos/tests>' -A login.test

Diffstat (limited to 'src/libexpr/common-opts.cc')
-rw-r--r--src/libexpr/common-opts.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/libexpr/common-opts.cc b/src/libexpr/common-opts.cc
index d029d2ec35b9..e0865d9fcc25 100644
--- a/src/libexpr/common-opts.cc
+++ b/src/libexpr/common-opts.cc
@@ -44,4 +44,15 @@ bool parseSearchPathArg(const string & arg, Strings::iterator & i,
 }
 
 
+Path lookupFileArg(EvalState & state, string s)
+{
+    if (s.size() > 2 && s.at(0) == '<' && s.at(s.size() - 1) == '>') {
+        Path p = state.findFile(s.substr(1, s.size() - 2));
+        if (p == "") throw Error(format("file `%1%' was not found in the Nix search path (add it using $NIX_PATH or -I)") % p);
+        return p;
+    } else
+        return absPath(s);
+}
+
+
 }