From ce92d1bf1434562f5b80320c503768c4d06f1f8d Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 18 Nov 2003 11:22:29 +0000 Subject: [PATCH] * "Nix expression" -> "store expression". * More refactoring. --- src/fix-ng/Makefile.am | 2 +- src/fix-ng/eval.cc | 1 - src/fix-ng/eval.hh | 5 ++- src/fix-ng/fix.cc | 1 - src/fix-ng/{fix-expr.cc => fixexpr.cc} | 4 +- src/fix-ng/{fix-expr.hh => fixexpr.hh} | 0 src/fix-ng/parser.cc | 4 +- src/fix-ng/parser.hh | 2 +- src/fix-ng/primops.cc | 28 ++++++------- src/libstore/Makefile.am | 2 +- src/libstore/normalise.cc | 54 +++++++++++++------------- src/libstore/normalise.hh | 32 ++++++++------- src/libstore/{expr.cc => storeexpr.cc} | 31 +++++---------- src/libstore/{expr.hh => storeexpr.hh} | 24 +++++------- src/libutil/aterm.cc | 13 +++++++ src/libutil/aterm.hh | 5 +++ src/nix/dotgraph.cc | 8 ++-- src/nix/dotgraph.hh | 2 +- src/nix/nix-help.txt | 4 +- src/nix/nix.cc | 18 ++++----- 20 files changed, 121 insertions(+), 119 deletions(-) rename src/fix-ng/{fix-expr.cc => fixexpr.cc} (99%) rename src/fix-ng/{fix-expr.hh => fixexpr.hh} (100%) rename src/libstore/{expr.cc => storeexpr.cc} (87%) rename src/libstore/{expr.hh => storeexpr.hh} (59%) diff --git a/src/fix-ng/Makefile.am b/src/fix-ng/Makefile.am index df3d17308..d30a5b2ea 100644 --- a/src/fix-ng/Makefile.am +++ b/src/fix-ng/Makefile.am @@ -1,6 +1,6 @@ bin_PROGRAMS = fix-ng -fix_ng_SOURCES = fix-expr.cc parser.cc eval.cc primops.cc fix.cc +fix_ng_SOURCES = fixexpr.cc parser.cc eval.cc primops.cc fix.cc fix_ng_LDADD = ../libmain/libmain.a ../libstore/libstore.a ../libutil/libutil.a \ ../boost/format/libformat.a -L../../externals/inst/lib -ldb_cxx \ -lsglr -lATB -lconversion -lasfix2 -lmept -lATerm diff --git a/src/fix-ng/eval.cc b/src/fix-ng/eval.cc index 57cca4c4a..b110c3a4a 100644 --- a/src/fix-ng/eval.cc +++ b/src/fix-ng/eval.cc @@ -1,5 +1,4 @@ #include "eval.hh" -#include "expr.hh" #include "parser.hh" #include "primops.hh" diff --git a/src/fix-ng/eval.hh b/src/fix-ng/eval.hh index 9be3ae2da..061c840a7 100644 --- a/src/fix-ng/eval.hh +++ b/src/fix-ng/eval.hh @@ -3,8 +3,9 @@ #include -#include "fix-expr.hh" -#include "expr.hh" +#include "aterm.hh" +#include "hash.hh" +#include "fixexpr.hh" typedef map DrvPaths; diff --git a/src/fix-ng/fix.cc b/src/fix-ng/fix.cc index 3b7dae38e..e407aaf44 100644 --- a/src/fix-ng/fix.cc +++ b/src/fix-ng/fix.cc @@ -4,7 +4,6 @@ #include "globals.hh" #include "normalise.hh" #include "shared.hh" -#include "expr.hh" #include "eval.hh" diff --git a/src/fix-ng/fix-expr.cc b/src/fix-ng/fixexpr.cc similarity index 99% rename from src/fix-ng/fix-expr.cc rename to src/fix-ng/fixexpr.cc index e9c5a3ba6..721fa8afa 100644 --- a/src/fix-ng/fix-expr.cc +++ b/src/fix-ng/fixexpr.cc @@ -1,5 +1,5 @@ -#include "fix-expr.hh" -#include "expr.hh" +#include "fixexpr.hh" +#include "storeexpr.hh" ATermMap::ATermMap(unsigned int initialSize, unsigned int maxLoadPct) diff --git a/src/fix-ng/fix-expr.hh b/src/fix-ng/fixexpr.hh similarity index 100% rename from src/fix-ng/fix-expr.hh rename to src/fix-ng/fixexpr.hh diff --git a/src/fix-ng/parser.cc b/src/fix-ng/parser.cc index 710ea6a86..eaa41b396 100644 --- a/src/fix-ng/parser.cc +++ b/src/fix-ng/parser.cc @@ -10,10 +10,10 @@ extern "C" { #include } +#include "aterm.hh" #include "parser.hh" #include "shared.hh" -#include "fix-expr.hh" -#include "expr.hh" +#include "fixexpr.hh" #include "parse-table.h" diff --git a/src/fix-ng/parser.hh b/src/fix-ng/parser.hh index c56a339a3..e44987dd0 100644 --- a/src/fix-ng/parser.hh +++ b/src/fix-ng/parser.hh @@ -1,7 +1,7 @@ #ifndef __PARSER_H #define __PARSER_H -#include "fix-expr.hh" +#include "fixexpr.hh" Expr parseExprFromFile(Path path); diff --git a/src/fix-ng/primops.cc b/src/fix-ng/primops.cc index 86b364c30..097933115 100644 --- a/src/fix-ng/primops.cc +++ b/src/fix-ng/primops.cc @@ -13,22 +13,22 @@ Expr primImport(EvalState & state, Expr arg) } -static PathSet nixExprRootsCached(EvalState & state, const Path & nePath) +static PathSet storeExprRootsCached(EvalState & state, const Path & nePath) { DrvPaths::iterator i = state.drvPaths.find(nePath); if (i != state.drvPaths.end()) return i->second; else { - PathSet paths = nixExprRoots(nePath); + PathSet paths = storeExprRoots(nePath); state.drvPaths[nePath] = paths; return paths; } } -static Hash hashDerivation(EvalState & state, NixExpr ne) +static Hash hashDerivation(EvalState & state, StoreExpr ne) { - if (ne.type == NixExpr::neDerivation) { + if (ne.type == StoreExpr::neDerivation) { PathSet inputs2; for (PathSet::iterator i = ne.derivation.inputs.begin(); i != ne.derivation.inputs.end(); i++) @@ -40,7 +40,7 @@ static Hash hashDerivation(EvalState & state, NixExpr ne) } ne.derivation.inputs = inputs2; } - return hashTerm(unparseNixExpr(ne)); + return hashTerm(unparseStoreExpr(ne)); } @@ -50,13 +50,13 @@ static Path copyAtom(EvalState & state, const Path & srcPath) Path dstPath(addToStore(srcPath)); ClosureElem elem; - NixExpr ne; - ne.type = NixExpr::neClosure; + StoreExpr ne; + ne.type = StoreExpr::neClosure; ne.closure.roots.insert(dstPath); ne.closure.elems[dstPath] = elem; Hash drvHash = hashDerivation(state, ne); - Path drvPath = writeTerm(unparseNixExpr(ne), ""); + Path drvPath = writeTerm(unparseStoreExpr(ne), ""); state.drvHashes[drvPath] = drvHash; printMsg(lvlChatty, format("copied `%1%' -> closure `%2%'") @@ -66,9 +66,9 @@ static Path copyAtom(EvalState & state, const Path & srcPath) static string addInput(EvalState & state, - Path & nePath, NixExpr & ne) + Path & nePath, StoreExpr & ne) { - PathSet paths = nixExprRootsCached(state, nePath); + PathSet paths = storeExprRootsCached(state, nePath); if (paths.size() != 1) abort(); Path path = *(paths.begin()); ne.derivation.inputs.insert(nePath); @@ -76,7 +76,7 @@ static string addInput(EvalState & state, } -static string processBinding(EvalState & state, Expr e, NixExpr & ne) +static string processBinding(EvalState & state, Expr e, StoreExpr & ne) { e = evalExpr(state, e); @@ -131,8 +131,8 @@ Expr primDerivation(EvalState & state, Expr args) queryAllAttrs(args, attrs); /* Build the derivation expression by processing the attributes. */ - NixExpr ne; - ne.type = NixExpr::neDerivation; + StoreExpr ne; + ne.type = StoreExpr::neDerivation; string drvName; Path outPath; @@ -198,7 +198,7 @@ Expr primDerivation(EvalState & state, Expr args) Hash drvHash = outHashGiven ? hashString((string) outHash + outPath) : hashDerivation(state, ne); - Path drvPath = writeTerm(unparseNixExpr(ne), "-d-" + drvName); + Path drvPath = writeTerm(unparseStoreExpr(ne), "-d-" + drvName); state.drvHashes[drvPath] = drvHash; printMsg(lvlChatty, format("instantiated `%1%' -> `%2%'") diff --git a/src/libstore/Makefile.am b/src/libstore/Makefile.am index 472b1b079..b365f57c6 100644 --- a/src/libstore/Makefile.am +++ b/src/libstore/Makefile.am @@ -1,7 +1,7 @@ noinst_LIBRARIES = libstore.a libstore_a_SOURCES = \ - store.cc expr.cc normalise.cc exec.cc \ + store.cc storeexpr.cc normalise.cc exec.cc \ globals.cc db.cc references.cc pathlocks.cc AM_CXXFLAGS = -DSYSTEM=\"@host@\" -Wall \ diff --git a/src/libstore/normalise.cc b/src/libstore/normalise.cc index cb2bf4f5b..c531e6784 100644 --- a/src/libstore/normalise.cc +++ b/src/libstore/normalise.cc @@ -18,21 +18,21 @@ static Path useSuccessor(const Path & path) } -Path normaliseNixExpr(const Path & _nePath, PathSet pending) +Path normaliseStoreExpr(const Path & _nePath, PathSet pending) { startNest(nest, lvlTalkative, - format("normalising expression in `%1%'") % (string) _nePath); + format("normalising store expression in `%1%'") % (string) _nePath); /* Try to substitute the expression by any known successors in order to speed up the rewrite process. */ Path nePath = useSuccessor(_nePath); - /* Get the Nix expression. */ - NixExpr ne = exprFromPath(nePath, pending); + /* Get the store expression. */ + StoreExpr ne = storeExprFromPath(nePath, pending); /* If this is a normal form (i.e., a closure) we are done. */ - if (ne.type == NixExpr::neClosure) return nePath; - if (ne.type != NixExpr::neDerivation) abort(); + if (ne.type == StoreExpr::neClosure) return nePath; + if (ne.type != StoreExpr::neDerivation) abort(); /* Otherwise, it's a derivation expression, and we have to build it to @@ -51,8 +51,8 @@ Path normaliseNixExpr(const Path & _nePath, PathSet pending) Environment env; /* The result. */ - NixExpr nf; - nf.type = NixExpr::neClosure; + StoreExpr nf; + nf.type = StoreExpr::neClosure; /* The outputs are referenceable paths. */ @@ -78,10 +78,10 @@ Path normaliseNixExpr(const Path & _nePath, PathSet pending) { Path nePath2 = useSuccessor(nePath); if (nePath != nePath2) { - NixExpr ne = exprFromPath(nePath2, pending); + StoreExpr ne = storeExprFromPath(nePath2, pending); debug(format("skipping build of expression `%1%', someone beat us to it") % (string) nePath); - if (ne.type != NixExpr::neClosure) abort(); + if (ne.type != StoreExpr::neClosure) abort(); return nePath2; } } @@ -95,12 +95,12 @@ Path normaliseNixExpr(const Path & _nePath, PathSet pending) for (PathSet::iterator i = ne.derivation.inputs.begin(); i != ne.derivation.inputs.end(); i++) { - Path nfPath = normaliseNixExpr(*i, pending); + Path nfPath = normaliseStoreExpr(*i, pending); realiseClosure(nfPath, pending); /* !!! nfPath should be a root of the garbage collector while we are building */ - NixExpr ne = exprFromPath(nfPath, pending); - if (ne.type != NixExpr::neClosure) abort(); + StoreExpr ne = storeExprFromPath(nfPath, pending); + if (ne.type != StoreExpr::neClosure) abort(); for (ClosureElems::iterator j = ne.closure.elems.begin(); j != ne.closure.elems.end(); j++) { @@ -238,7 +238,7 @@ Path normaliseNixExpr(const Path & _nePath, PathSet pending) /* Write the normal form. This does not have to occur in the transaction below because writing terms is idem-potent. */ - ATerm nfTerm = unparseNixExpr(nf); + ATerm nfTerm = unparseStoreExpr(nf); printMsg(lvlVomit, format("normal form: %1%") % atPrint(nfTerm)); Path nfPath = writeTerm(nfTerm, "-s"); @@ -264,8 +264,8 @@ void realiseClosure(const Path & nePath, PathSet pending) { startNest(nest, lvlDebug, format("realising closure `%1%'") % nePath); - NixExpr ne = exprFromPath(nePath, pending); - if (ne.type != NixExpr::neClosure) + StoreExpr ne = storeExprFromPath(nePath, pending); + if (ne.type != StoreExpr::neClosure) throw Error(format("expected closure in `%1%'") % nePath); for (ClosureElems::const_iterator i = ne.closure.elems.begin(); @@ -286,7 +286,7 @@ void ensurePath(const Path & path, PathSet pending) i != subPaths.end(); i++) { try { - normaliseNixExpr(*i, pending); + normaliseStoreExpr(*i, pending); if (isValidPath(path)) return; throw Error(format("substitute failed to produce expected output path")); } catch (Error & e) { @@ -301,24 +301,24 @@ void ensurePath(const Path & path, PathSet pending) } -NixExpr exprFromPath(const Path & path, PathSet pending) +StoreExpr storeExprFromPath(const Path & path, PathSet pending) { ensurePath(path, pending); ATerm t = ATreadFromNamedFile(path.c_str()); if (!t) throw Error(format("cannot read aterm from `%1%'") % path); - return parseNixExpr(t); + return parseStoreExpr(t); } -PathSet nixExprRoots(const Path & nePath) +PathSet storeExprRoots(const Path & nePath) { PathSet paths; - NixExpr ne = exprFromPath(nePath); + StoreExpr ne = storeExprFromPath(nePath); - if (ne.type == NixExpr::neClosure) + if (ne.type == StoreExpr::neClosure) paths.insert(ne.closure.roots.begin(), ne.closure.roots.end()); - else if (ne.type == NixExpr::neDerivation) + else if (ne.type == StoreExpr::neDerivation) paths.insert(ne.derivation.outputs.begin(), ne.derivation.outputs.end()); else abort(); @@ -334,14 +334,14 @@ static void requisitesWorker(const Path & nePath, if (doneSet.find(nePath) != doneSet.end()) return; doneSet.insert(nePath); - NixExpr ne = exprFromPath(nePath); + StoreExpr ne = storeExprFromPath(nePath); - if (ne.type == NixExpr::neClosure) + if (ne.type == StoreExpr::neClosure) for (ClosureElems::iterator i = ne.closure.elems.begin(); i != ne.closure.elems.end(); i++) paths.insert(i->first); - else if (ne.type == NixExpr::neDerivation) + else if (ne.type == StoreExpr::neDerivation) for (PathSet::iterator i = ne.derivation.inputs.begin(); i != ne.derivation.inputs.end(); i++) requisitesWorker(*i, @@ -358,7 +358,7 @@ static void requisitesWorker(const Path & nePath, } -PathSet nixExprRequisites(const Path & nePath, +PathSet storeExprRequisites(const Path & nePath, bool includeExprs, bool includeSuccessors) { PathSet paths; diff --git a/src/libstore/normalise.hh b/src/libstore/normalise.hh index bbe846404..1003858cb 100644 --- a/src/libstore/normalise.hh +++ b/src/libstore/normalise.hh @@ -1,16 +1,16 @@ #ifndef __NORMALISE_H #define __NORMALISE_H -#include "expr.hh" +#include "storeexpr.hh" -/* Normalise a Nix expression. That is, if the expression is a +/* Normalise a store expression. That is, if the expression is a derivation, a path containing an equivalent closure expression is returned. This requires that the derivation is performed, unless a successor is known. */ -Path normaliseNixExpr(const Path & nePath, PathSet pending = PathSet()); +Path normaliseStoreExpr(const Path & nePath, PathSet pending = PathSet()); -/* Realise a closure expression in the file system. +/* Realise a closure store expression in the file system. The pending paths are those that are already being realised. This prevents infinite recursion for paths realised through a substitute @@ -22,23 +22,25 @@ void realiseClosure(const Path & nePath, PathSet pending = PathSet()); realising a substitute. */ void ensurePath(const Path & path, PathSet pending = PathSet()); -/* Read a Nix expression, after ensuring its existence through +/* Read a store expression, after ensuring its existence through ensurePath(). */ -NixExpr exprFromPath(const Path & path, PathSet pending = PathSet()); +StoreExpr storeExprFromPath(const Path & path, PathSet pending = PathSet()); -/* Get the list of root (output) paths of the given Nix expression. */ -PathSet nixExprRoots(const Path & nePath); +/* Get the list of root (output) paths of the given store + expression. */ +PathSet storeExprRoots(const Path & nePath); -/* Get the list of paths that are required to realise the given +/* Get the list of paths that are required to realise the given store expression. For a derive expression, this is the union of - requisites of the inputs; for a closure expression, it is the path of - each element in the closure. If `includeExprs' is true, include the - paths of the Nix expressions themselves. If `includeSuccessors' is - true, include the requisites of successors. */ -PathSet nixExprRequisites(const Path & nePath, + requisites of the inputs; for a closure expression, it is the path + of each element in the closure. If `includeExprs' is true, include + the paths of the store expressions themselves. If + `includeSuccessors' is true, include the requisites of + successors. */ +PathSet storeExprRequisites(const Path & nePath, bool includeExprs, bool includeSuccessors); -/* Return the list of the paths of all known Nix expressions whose +/* Return the list of the paths of all known store expressions whose output paths are completely contained in the set `outputs'. */ PathSet findGenerators(const PathSet & outputs); diff --git a/src/libstore/expr.cc b/src/libstore/storeexpr.cc similarity index 87% rename from src/libstore/expr.cc rename to src/libstore/storeexpr.cc index 7bb1f5306..e11cd5bfe 100644 --- a/src/libstore/expr.cc +++ b/src/libstore/storeexpr.cc @@ -1,21 +1,8 @@ -#include "expr.hh" +#include "storeexpr.hh" #include "globals.hh" #include "store.hh" -Error badTerm(const format & f, ATerm t) -{ - char * s = ATwriteToString(t); - if (!s) throw Error("cannot print term"); - if (strlen(s) > 1000) { - int len; - s = ATwriteToSharedString(t, &len); - if (!s) throw Error("cannot print term"); - } - return Error(format("%1%, in `%2%'") % f.str() % (string) s); -} - - Hash hashTerm(ATerm t) { return hashString(atPrint(t)); @@ -138,14 +125,14 @@ static bool parseDerivation(ATerm t, Derivation & derivation) } -NixExpr parseNixExpr(ATerm t) +StoreExpr parseStoreExpr(ATerm t) { - NixExpr ne; + StoreExpr ne; if (parseClosure(t, ne.closure)) - ne.type = NixExpr::neClosure; + ne.type = StoreExpr::neClosure; else if (parseDerivation(t, ne.derivation)) - ne.type = NixExpr::neDerivation; - else throw badTerm("not a Nix expression", t); + ne.type = StoreExpr::neDerivation; + else throw badTerm("not a store expression", t); return ne; } @@ -200,11 +187,11 @@ static ATerm unparseDerivation(const Derivation & derivation) } -ATerm unparseNixExpr(const NixExpr & ne) +ATerm unparseStoreExpr(const StoreExpr & ne) { - if (ne.type == NixExpr::neClosure) + if (ne.type == StoreExpr::neClosure) return unparseClosure(ne.closure); - else if (ne.type == NixExpr::neDerivation) + else if (ne.type == StoreExpr::neDerivation) return unparseDerivation(ne.derivation); else abort(); } diff --git a/src/libstore/expr.hh b/src/libstore/storeexpr.hh similarity index 59% rename from src/libstore/expr.hh rename to src/libstore/storeexpr.hh index f5abf9af0..07676c3cc 100644 --- a/src/libstore/expr.hh +++ b/src/libstore/storeexpr.hh @@ -1,11 +1,11 @@ -#ifndef __FSTATE_H -#define __FSTATE_H +#ifndef __STOREEXPR_H +#define __STOREEXPR_H #include "aterm.hh" #include "store.hh" -/* Abstract syntax of Nix expressions. */ +/* Abstract syntax of store expressions. */ struct ClosureElem { @@ -25,14 +25,14 @@ typedef map StringPairs; struct Derivation { PathSet outputs; - PathSet inputs; /* Nix expressions, not actual inputs */ + PathSet inputs; /* Store expressions, not actual inputs */ string platform; Path builder; Strings args; StringPairs env; }; -struct NixExpr +struct StoreExpr { enum { neClosure, neDerivation } type; Closure closure; @@ -40,21 +40,17 @@ struct NixExpr }; -/* Throw an exception with an error message containing the given - aterm. */ -Error badTerm(const format & f, ATerm t); - /* Hash an aterm. */ Hash hashTerm(ATerm t); /* Write an aterm to the Nix store directory, and return its path. */ Path writeTerm(ATerm t, const string & suffix); -/* Parse a Nix expression. */ -NixExpr parseNixExpr(ATerm t); +/* Parse a store expression. */ +StoreExpr parseStoreExpr(ATerm t); -/* Parse a Nix expression. */ -ATerm unparseNixExpr(const NixExpr & ne); +/* Parse a store expression. */ +ATerm unparseStoreExpr(const StoreExpr & ne); -#endif /* !__FSTATE_H */ +#endif /* !__STOREEXPR_H */ diff --git a/src/libutil/aterm.cc b/src/libutil/aterm.cc index de7c35952..dc6abf9e7 100644 --- a/src/libutil/aterm.cc +++ b/src/libutil/aterm.cc @@ -91,3 +91,16 @@ ATMatcher & operator >> (ATMatcher & pos, ATermList & out) out = (ATermList) t; return pos; } + + +Error badTerm(const format & f, ATerm t) +{ + char * s = ATwriteToString(t); + if (!s) throw Error("cannot print term"); + if (strlen(s) > 1000) { + int len; + s = ATwriteToSharedString(t, &len); + if (!s) throw Error("cannot print term"); + } + return Error(format("%1%, in `%2%'") % f.str() % (string) s); +} diff --git a/src/libutil/aterm.hh b/src/libutil/aterm.hh index 16d8d6bb6..d38d8e3f4 100644 --- a/src/libutil/aterm.hh +++ b/src/libutil/aterm.hh @@ -74,4 +74,9 @@ ATMatcher & operator >> (ATMatcher & pos, const string & s); ATMatcher & operator >> (ATMatcher & pos, ATermList & out); +/* Throw an exception with an error message containing the given + aterm. */ +Error badTerm(const format & f, ATerm t); + + #endif /* !__ATERM_H */ diff --git a/src/nix/dotgraph.cc b/src/nix/dotgraph.cc index 36daf7f99..c670bf19e 100644 --- a/src/nix/dotgraph.cc +++ b/src/nix/dotgraph.cc @@ -52,7 +52,7 @@ string pathLabel(const Path & nePath, const string & elemPath) } -void printClosure(const Path & nePath, const NixExpr & fs) +void printClosure(const Path & nePath, const StoreExpr & fs) { PathSet workList(fs.closure.roots); PathSet doneSet; @@ -100,11 +100,11 @@ void printDotGraph(const PathSet & roots) if (doneSet.find(nePath) == doneSet.end()) { doneSet.insert(nePath); - NixExpr ne = exprFromPath(nePath); + StoreExpr ne = storeExprFromPath(nePath); string label, colour; - if (ne.type == NixExpr::neDerivation) { + if (ne.type == StoreExpr::neDerivation) { for (PathSet::iterator i = ne.derivation.inputs.begin(); i != ne.derivation.inputs.end(); i++) { @@ -119,7 +119,7 @@ void printDotGraph(const PathSet & roots) if (i->first == "name") label = i->second; } - else if (ne.type == NixExpr::neClosure) { + else if (ne.type == StoreExpr::neClosure) { label = ""; colour = "#00ffff"; printClosure(nePath, ne); diff --git a/src/nix/dotgraph.hh b/src/nix/dotgraph.hh index a5c5248f1..ef389b30d 100644 --- a/src/nix/dotgraph.hh +++ b/src/nix/dotgraph.hh @@ -1,7 +1,7 @@ #ifndef __DOTGRAPH_H #define __DOTGRAPH_H -#include "expr.hh" +#include "storeexpr.hh" void printDotGraph(const PathSet & roots); diff --git a/src/nix/nix-help.txt b/src/nix/nix-help.txt index bf2afd061..a2d9958ff 100644 --- a/src/nix/nix-help.txt +++ b/src/nix/nix-help.txt @@ -2,7 +2,7 @@ nix [OPTIONS...] [ARGUMENTS...] Operations: - --install / -i: realise a Nix expression + --realise / -r: realise a Nix expression --delete / -d: delete paths from the Nix store --add / -A: copy a path to the Nix store --query / -q: query information @@ -22,7 +22,7 @@ Operations: Query flags: --list / -l: query the output paths (roots) of a Nix expression (default) - --requisites / -r: print all paths necessary to realise expression + --requisites / -R: print all paths necessary to realise expression --predecessors: print predecessors of a Nix expression --graph: print a dot graph rooted at given ids diff --git a/src/nix/nix.cc b/src/nix/nix.cc index 187568999..d1766de39 100644 --- a/src/nix/nix.cc +++ b/src/nix/nix.cc @@ -27,15 +27,15 @@ static Path checkPath(const Path & arg) } -/* Realise (or install) paths from the given Nix expressions. */ -static void opInstall(Strings opFlags, Strings opArgs) +/* Realise paths from the given store expressions. */ +static void opRealise(Strings opFlags, Strings opArgs) { if (!opFlags.empty()) throw UsageError("unknown flag"); for (Strings::iterator i = opArgs.begin(); i != opArgs.end(); i++) { - Path nfPath = normaliseNixExpr(checkPath(*i)); + Path nfPath = normaliseStoreExpr(checkPath(*i)); realiseClosure(nfPath); cout << format("%1%\n") % (string) nfPath; } @@ -66,7 +66,7 @@ static void opAdd(Strings opFlags, Strings opArgs) Path maybeNormalise(const Path & ne, bool normalise) { - return normalise ? normaliseNixExpr(ne) : ne; + return normalise ? normaliseStoreExpr(ne) : ne; } @@ -82,7 +82,7 @@ static void opQuery(Strings opFlags, Strings opArgs) for (Strings::iterator i = opFlags.begin(); i != opFlags.end(); i++) if (*i == "--list" || *i == "-l") query = qList; - else if (*i == "--requisites" || *i == "-r") query = qRequisites; + else if (*i == "--requisites" || *i == "-R") query = qRequisites; else if (*i == "--predecessors") query = qPredecessors; else if (*i == "--graph") query = qGraph; else if (*i == "--normalise" || *i == "-n") normalise = true; @@ -96,7 +96,7 @@ static void opQuery(Strings opFlags, Strings opArgs) for (Strings::iterator i = opArgs.begin(); i != opArgs.end(); i++) { - StringSet paths = nixExprRoots( + StringSet paths = storeExprRoots( maybeNormalise(checkPath(*i), normalise)); for (StringSet::iterator j = paths.begin(); j != paths.end(); j++) @@ -110,7 +110,7 @@ static void opQuery(Strings opFlags, Strings opArgs) for (Strings::iterator i = opArgs.begin(); i != opArgs.end(); i++) { - StringSet paths2 = nixExprRequisites( + StringSet paths2 = storeExprRequisites( maybeNormalise(checkPath(*i), normalise), includeExprs, includeSuccessors); paths.insert(paths2.begin(), paths2.end()); @@ -258,8 +258,8 @@ void run(Strings args) Operation oldOp = op; - if (arg == "--install" || arg == "-i") - op = opInstall; + if (arg == "--realise" || arg == "-r") + op = opRealise; else if (arg == "--delete" || arg == "-d") op = opDelete; else if (arg == "--add" || arg == "-A")