* Option `--force-realise' in `nix-store --query'.

This commit is contained in:
Eelco Dolstra 2004-01-09 14:18:28 +00:00
parent 30b31a8f61
commit 46a71c857c
4 changed files with 98 additions and 74 deletions

View File

@ -7,18 +7,14 @@
<refsynopsisdiv>
<cmdsynopsis>
<command>nix-env</command>
<group choice='opt' rep='repeat'>
<arg><option>--verbose</option></arg>
<arg><option>-v</option></arg>
</group>
<group choice='opt'>
<arg><option>--keep-failed</option></arg>
<arg><option>-K</option></arg>
</group>
<arg rep='repeat'><option>--verbose</option></arg>
<arg rep='repeat'><option>-v</option></arg>
<arg><option>--keep-failed</option></arg>
<arg><option>-K</option></arg>
<arg>
<group choice='opt'>
<arg><option>--file</option></arg>
<arg><option>-f</option></arg>
<group choice='req'>
<arg choice='plain'><option>--file</option></arg>
<arg choice='plain'><option>-f</option></arg>
</group>
<replaceable>path</replaceable>
</arg>
@ -76,7 +72,7 @@
&opt-verbose;
<varlistentry>
<term><option>--file</option></term>
<term><option>--file</option> / <option>-f</option></term>
<listitem>
<para>
Specifies the Nix expression used by the
@ -125,8 +121,8 @@
By default, it points to
<filename><replaceable>prefix</replaceable>/var/nix/links/current</filename>.
The <envar>PATH</envar> environment variable should
include <filename>~/.nix-userenv</filename> for the use
environments to be visible to the user.
include <filename>~/.nix-userenv</filename> for the user
environment to be visible to the user.
</para>
</listitem>
</varlistentry>
@ -146,8 +142,9 @@
<title>Synopsis</title>
<cmdsynopsis>
<command>nix-env</command>
<group>
<arg><option>--install</option></arg>
<group choice='req'>
<arg choice='plain'><option>--install</option></arg>
<arg choice='plain'><option>-i</option></arg>
</group>
</cmdsynopsis>
</refsection>

View File

@ -7,14 +7,10 @@
<refsynopsisdiv>
<cmdsynopsis>
<command>nix-store</command>
<group choice='opt' rep='repeat'>
<arg><option>--verbose</option></arg>
<arg><option>-v</option></arg>
</group>
<group choice='opt'>
<arg><option>--keep-failed</option></arg>
<arg><option>-K</option></arg>
</group>
<arg rep='repeat'><option>--verbose</option></arg>
<arg rep='repeat'><option>-v</option></arg>
<arg><option>--keep-failed</option></arg>
<arg><option>-K</option></arg>
<arg choice='plain'><replaceable>operation</replaceable></arg>
<arg rep='repeat'><replaceable>options</replaceable></arg>
<arg rep='repeat'><replaceable>arguments</replaceable></arg>
@ -56,7 +52,7 @@
&opt-verbose;
<varlistentry>
<term><option>--keep-failed</option></term>
<term><option>--keep-failed</option> / <option>-K</option></term>
<listitem>
<para>
Specifies that in case of a build failure, the temporary directory
@ -112,9 +108,9 @@
<title>Synopsis</title>
<cmdsynopsis>
<command>nix-store</command>
<group>
<arg><option>--realise</option></arg>
<arg><option>-r</option></arg>
<group choice='req'>
<arg choice='plain'><option>--realise</option></arg>
<arg choice='plain'><option>-r</option></arg>
</group>
<arg choice='plain' rep='repeat'><replaceable>paths</replaceable></arg>
</cmdsynopsis>
@ -160,9 +156,9 @@
<title>Synopsis</title>
<cmdsynopsis>
<command>nix-store</command>
<group>
<arg><option>--delete</option></arg>
<arg><option>-d</option></arg>
<group choice='req'>
<arg choice='plain'><option>--delete</option></arg>
<arg choice='plain'><option>-d</option></arg>
</group>
<arg choice='plain' rep='repeat'><replaceable>paths</replaceable></arg>
</cmdsynopsis>
@ -203,22 +199,22 @@
<title>Synopsis</title>
<cmdsynopsis>
<command>nix-store</command>
<group>
<arg><option>--query</option></arg>
<arg><option>-q</option></arg>
<group choice='req'>
<arg choice='plain'><option>--query</option></arg>
<arg choice='plain'><option>-q</option></arg>
</group>
<group>
<group>
<arg><option>--list</option></arg>
<arg><option>-l</option></arg>
</group>
<group>
<arg><option>--requisites</option></arg>
<arg><option>-R</option></arg>
</group>
<arg><option>--predecessors</option></arg>
<arg><option>--graph</option></arg>
<group choice='req'>
<arg choice='plain'><option>--list</option></arg>
<arg choice='plain'><option>-l</option></arg>
<arg choice='plain'><option>--requisites</option></arg>
<arg choice='plain'><option>-R</option></arg>
<arg choice='plain'><option>--predecessors</option></arg>
<arg choice='plain'><option>--graph</option></arg>
</group>
<arg><option>--normalise</option></arg>
<arg><option>-n</option></arg>
<arg><option>--force-realise</option></arg>
<arg><option>-f</option></arg>
<arg choice='plain' rep='repeat'><replaceable>args</replaceable></arg>
</cmdsynopsis>
</refsection>
@ -235,13 +231,55 @@
</refsection>
<refsection>
<title>Common query options</title>
<variablelist>
<varlistentry>
<term><option>--normalise</option> / <option>-n</option></term>
<listitem>
<para>
For those queries that take a Nix store expression, this
option causes those expressions to be normalised first.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--force-realise</option> / <option>-f</option></term>
<listitem>
<para>
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
</para>
<screen>
nix-store --realise /nix/store/bla.store
x=`nix-store --query --normalise /nix/store/bla.store
<emphasis>(do something with the path $x</emphasis></screen>
<para>
which using this flag can be written as
</para>
<screen>
x=`nix-store --query --normalise --force-realise /nix/store/bla.store
<emphasis>(do something with the path $x</emphasis></screen>
</listitem>
</varlistentry>
</variablelist>
</refsection>
<refsection id='nixref-queries'>
<title>Queries</title>
<variablelist>
<varlistentry>
<term><option>--list</option></term>
<term><option>--list</option> / <option>-l</option></term>
<listitem>
<para>
Prints out the <emphasis>output paths</emphasis> of the
@ -257,7 +295,7 @@
</varlistentry>
<varlistentry>
<term><option>--requisites</option></term>
<term><option>--requisites</option> / <option>-R</option></term>
<listitem>
<para>
Prints out the requisite paths of the store expressions
@ -304,18 +342,6 @@
<variablelist>
<varlistentry>
<term><option>--normalise</option></term>
<listitem>
<para>
Causes the requisite paths of the
<emphasis>successor</emphasis> of the given store
expressions to be printed, rather than the
requisite paths of the expressions themselves.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--exclude-exprs</option></term>
<listitem>
@ -398,9 +424,7 @@
<title>Synopsis</title>
<cmdsynopsis>
<command>nix-store</command>
<group>
<arg><option>--successor</option></arg>
</group>
<arg choice='req'><option>--successor</option></arg>
<arg choice='plain'
rep='repeat'><replaceable>srcpath</replaceable> <replaceable>sucpath</replaceable></arg>
</cmdsynopsis>
@ -432,9 +456,7 @@
<title>Synopsis</title>
<cmdsynopsis>
<command>nix-store</command>
<group>
<arg><option>--substitute</option></arg>
</group>
<arg choice='req'><option>--substitute</option></arg>
<arg choice='plain'
rep='repeat'><replaceable>srcpath</replaceable> <replaceable>subpath</replaceable></arg>
</cmdsynopsis>
@ -466,9 +488,7 @@
<title>Synopsis</title>
<cmdsynopsis>
<command>nix-store</command>
<group>
<arg><option>--verify</option></arg>
</group>
<arg choice='req'><option>--verify</option></arg>
</cmdsynopsis>
</refsection>

View File

@ -1,5 +1,5 @@
<varlistentry>
<term><option>--verbose</option></term>
<term><option>--verbose</option> / <option>-v</option></term>
<listitem>
<para>
Increases the level of verbosity of diagnostic messages printed

View File

@ -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;
}