aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2004-01-05 16:26:43 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2004-01-05 16:26:43 +0000
commit4a373a3e9ac07a2d4c43d495c0a44883106ecfde (patch)
tree27f4e22f8d3573bfe1ebba1acfa2e46a735fecee /src/libexpr
parentf83c5e3e5f3e6b33c095d6559a4b3cd5922e88ce (diff)
* Implemented Eelco V.'s `nix-env -I' command to specify the default
path of the Nix expression to be used with the import, upgrade, and query commands. For instance, $ nix-env -I ~/nixpkgs/pkgs/system/i686-linux.nix $ nix-env --query --available [aka -qa] sylpheed-0.9.7 bison-1.875 pango-1.2.5 subversion-0.35.1 ... $ nix-env -i sylpheed $ nix-env -u subversion There can be only one default at a time. * If the path to a Nix expression is a symlink, follow the symlink prior to resolving relative path references in the expression.
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/parser.cc18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/libexpr/parser.cc b/src/libexpr/parser.cc
index aecfa4348..b9e79e13d 100644
--- a/src/libexpr/parser.cc
+++ b/src/libexpr/parser.cc
@@ -29,16 +29,12 @@ struct Cleanup : TermFun
ATMatcher m;
string s;
- if (atMatch(m, e) >> "Str" >> s) {
+ if (atMatch(m, e) >> "Str" >> s)
return ATmake("Str(<str>)",
string(s, 1, s.size() - 2).c_str());
- }
- if (atMatch(m, e) >> "Path" >> s) {
- if (s[0] != '/')
- s = basePath + "/" + s;
- return ATmake("Path(<str>)", canonPath(s).c_str());
- }
+ if (atMatch(m, e) >> "Path" >> s)
+ return ATmake("Path(<str>)", absPath(s, basePath).c_str());
if (atMatch(m, e) >> "Int" >> s) {
istringstream s2(s);
@@ -147,8 +143,14 @@ Expr parseExprFromFile(Path path)
if (e) return e;
#endif
- /* If `path' refers to a directory, append `/default.nix'. */
+ /* If `path' is a symlink, follow it. This is so that relative
+ path references work. */
struct stat st;
+ if (lstat(path.c_str(), &st))
+ throw SysError(format("getting status of `%1%'") % path);
+ if (S_ISLNK(st.st_mode)) path = absPath(readLink(path), dirOf(path));
+
+ /* If `path' refers to a directory, append `/default.nix'. */
if (stat(path.c_str(), &st))
throw SysError(format("getting status of `%1%'") % path);
if (S_ISDIR(st.st_mode))