From 46a71c857c617b5acbf3d1fdb8fb7e676a4881a2 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 9 Jan 2004 14:18:28 +0000 Subject: [PATCH] * Option `--force-realise' in `nix-store --query'. --- doc/manual/nix-env.xml | 29 ++++----- doc/manual/nix-store.xml | 124 +++++++++++++++++++++---------------- doc/manual/opt-verbose.xml | 2 +- src/nix-store/main.cc | 17 +++-- 4 files changed, 98 insertions(+), 74 deletions(-) diff --git a/doc/manual/nix-env.xml b/doc/manual/nix-env.xml index d8b50bf3c..702faa621 100644 --- a/doc/manual/nix-env.xml +++ b/doc/manual/nix-env.xml @@ -7,18 +7,14 @@ nix-env - - - - - - - - + + + + - - - + + + path @@ -76,7 +72,7 @@ &opt-verbose; - + / Specifies the Nix expression used by the @@ -125,8 +121,8 @@ By default, it points to prefix/var/nix/links/current. The PATH environment variable should - include ~/.nix-userenv for the use - environments to be visible to the user. + include ~/.nix-userenv for the user + environment to be visible to the user. @@ -146,8 +142,9 @@ Synopsis nix-env - - + + + diff --git a/doc/manual/nix-store.xml b/doc/manual/nix-store.xml index cbd38cd23..479c1c3b0 100644 --- a/doc/manual/nix-store.xml +++ b/doc/manual/nix-store.xml @@ -7,14 +7,10 @@ nix-store - - - - - - - - + + + + operation options arguments @@ -56,7 +52,7 @@ &opt-verbose; - + / Specifies that in case of a build failure, the temporary directory @@ -112,9 +108,9 @@ Synopsis nix-store - - - + + + paths @@ -160,9 +156,9 @@ Synopsis nix-store - - - + + + paths @@ -203,22 +199,22 @@ Synopsis nix-store - - - + + + - - - - - - - - - - - + + + + + + + + + + + args @@ -235,13 +231,55 @@ + + + Common query options + + + + + / + + + For those queries that take a Nix store expression, this + option causes those expressions to be normalised first. + + + + + + / + + + For those queries that take a Nix store expression, this + option causes those expressions to be realised first. + This is just a short-cut for the common idiom + + +nix-store --realise /nix/store/bla.store +x=`nix-store --query --normalise /nix/store/bla.store +(do something with the path $x + + which using this flag can be written as + + +x=`nix-store --query --normalise --force-realise /nix/store/bla.store +(do something with the path $x + + + + + + + + Queries - + / Prints out the output paths of the @@ -257,7 +295,7 @@ - + / Prints out the requisite paths of the store expressions @@ -304,18 +342,6 @@ - - - - - Causes the requisite paths of the - successor of the given store - expressions to be printed, rather than the - requisite paths of the expressions themselves. - - - - @@ -398,9 +424,7 @@ Synopsis nix-store - - - + srcpath sucpath @@ -432,9 +456,7 @@ Synopsis nix-store - - - + srcpath subpath @@ -466,9 +488,7 @@ Synopsis nix-store - - - + diff --git a/doc/manual/opt-verbose.xml b/doc/manual/opt-verbose.xml index 5a1007a6a..3868acf30 100644 --- a/doc/manual/opt-verbose.xml +++ b/doc/manual/opt-verbose.xml @@ -1,5 +1,5 @@ - + / Increases the level of verbosity of diagnostic messages printed diff --git a/src/nix-store/main.cc b/src/nix-store/main.cc index 48752c2bf..078618a5d 100644 --- a/src/nix-store/main.cc +++ b/src/nix-store/main.cc @@ -61,9 +61,14 @@ static void opAdd(Strings opFlags, Strings opArgs) } -Path maybeNormalise(const Path & ne, bool normalise) +Path maybeNormalise(const Path & ne, bool normalise, bool realise) { - return normalise ? normaliseStoreExpr(ne) : ne; + if (realise) { + Path ne2 = normaliseStoreExpr(ne); + realiseClosure(ne2); + return normalise ? ne2 : ne; + } else + return normalise ? normaliseStoreExpr(ne) : ne; } @@ -73,6 +78,7 @@ static void opQuery(Strings opFlags, Strings opArgs) enum { qList, qRequisites, qPredecessors, qGraph } query = qList; bool normalise = false; + bool realise = false; bool includeExprs = true; bool includeSuccessors = false; @@ -83,6 +89,7 @@ static void opQuery(Strings opFlags, Strings opArgs) else if (*i == "--predecessors") query = qPredecessors; else if (*i == "--graph") query = qGraph; else if (*i == "--normalise" || *i == "-n") normalise = true; + else if (*i == "--force-realise" || *i == "-f") realise = true; else if (*i == "--exclude-exprs") includeExprs = false; else if (*i == "--include-successors") includeSuccessors = true; else throw UsageError(format("unknown flag `%1%'") % *i); @@ -94,7 +101,7 @@ static void opQuery(Strings opFlags, Strings opArgs) i != opArgs.end(); i++) { StringSet paths = storeExprRoots( - maybeNormalise(checkPath(*i), normalise)); + maybeNormalise(checkPath(*i), normalise, realise)); for (StringSet::iterator j = paths.begin(); j != paths.end(); j++) cout << format("%s\n") % *j; @@ -108,7 +115,7 @@ static void opQuery(Strings opFlags, Strings opArgs) i != opArgs.end(); i++) { StringSet paths2 = storeExprRequisites( - maybeNormalise(checkPath(*i), normalise), + maybeNormalise(checkPath(*i), normalise, realise), includeExprs, includeSuccessors); paths.insert(paths2.begin(), paths2.end()); } @@ -134,7 +141,7 @@ static void opQuery(Strings opFlags, Strings opArgs) PathSet roots; for (Strings::iterator i = opArgs.begin(); i != opArgs.end(); i++) - roots.insert(maybeNormalise(checkPath(*i), normalise)); + roots.insert(maybeNormalise(checkPath(*i), normalise, realise)); printDotGraph(roots); break; }