* Sort `nix-env -q' output by derivation name.

* `--version' flag for all commands.
* Manual updates.
This commit is contained in:
Eelco Dolstra 2004-02-02 10:51:54 +00:00
parent 47c003cb59
commit d9f30fe7c7
11 changed files with 83 additions and 56 deletions

View file

@ -8,7 +8,7 @@ XSLTPROC = $(ENV) $(xsltproc) $(xmlflags) --catalogs \
SOURCES = manual.xml introduction.xml installation.xml overview.xml \ SOURCES = manual.xml introduction.xml installation.xml overview.xml \
nix-env.xml nix-store.xml nix-instantiate.xml \ nix-env.xml nix-store.xml nix-instantiate.xml \
troubleshooting.xml bugs.xml opt-verbose.xml \ troubleshooting.xml bugs.xml opt-common.xml opt-common-syn.xml \
quick-start.xml style.css images quick-start.xml style.css images
manual.is-valid: $(SOURCES) version.xml manual.is-valid: $(SOURCES) version.xml

View file

@ -7,7 +7,8 @@
<!ENTITY quick-start SYSTEM "quick-start.xml"> <!ENTITY quick-start SYSTEM "quick-start.xml">
<!ENTITY installation SYSTEM "installation.xml"> <!ENTITY installation SYSTEM "installation.xml">
<!ENTITY overview SYSTEM "overview.xml"> <!ENTITY overview SYSTEM "overview.xml">
<!ENTITY opt-verbose SYSTEM "opt-verbose.xml"> <!ENTITY opt-common SYSTEM "opt-common.xml">
<!ENTITY opt-common-syn SYSTEM "opt-common-syn.xml">
<!ENTITY nix-env SYSTEM "nix-env.xml"> <!ENTITY nix-env SYSTEM "nix-env.xml">
<!ENTITY nix-store SYSTEM "nix-store.xml"> <!ENTITY nix-store SYSTEM "nix-store.xml">
<!ENTITY nix-instantiate SYSTEM "nix-instantiate.xml"> <!ENTITY nix-instantiate SYSTEM "nix-instantiate.xml">

View file

@ -7,12 +7,7 @@
<refsynopsisdiv> <refsynopsisdiv>
<cmdsynopsis> <cmdsynopsis>
<command>nix-env</command> <command>nix-env</command>
<arg rep='repeat'><option>--verbose</option></arg> &opt-common-syn;
<arg rep='repeat'><option>-v</option></arg>
<arg><option>--build-output</option></arg>
<arg><option>-B</option></arg>
<arg><option>--keep-failed</option></arg>
<arg><option>-K</option></arg>
<arg> <arg>
<group choice='req'> <group choice='req'>
<arg choice='plain'><option>--file</option></arg> <arg choice='plain'><option>--file</option></arg>
@ -71,7 +66,7 @@
<variablelist> <variablelist>
&opt-verbose; &opt-common;
<varlistentry> <varlistentry>
<term><option>--file</option> / <option>-f</option></term> <term><option>--file</option> / <option>-f</option></term>

View file

@ -1,16 +1,13 @@
<refentry> <refentry>
<refnamediv> <refnamediv>
<refname>nix-instantiate</refname> <refname>nix-instantiate</refname>
<refpurpose>generate Nix expressions from a high-level description</refpurpose> <refpurpose>instantiate store expressions from Nix expressions</refpurpose>
</refnamediv> </refnamediv>
<refsynopsisdiv> <refsynopsisdiv>
<cmdsynopsis> <cmdsynopsis>
<command>fix</command> <command>nix-instantiate</command>
<group choice='opt' rep='repeat'> &opt-common-syn;
<arg><option>--verbose</option></arg>
<arg><option>-v</option></arg>
</group>
<arg rep='repeat'><replaceable>files</replaceable></arg> <arg rep='repeat'><replaceable>files</replaceable></arg>
</cmdsynopsis> </cmdsynopsis>
</refsynopsisdiv> </refsynopsisdiv>
@ -19,19 +16,10 @@
<title>Description</title> <title>Description</title>
<para> <para>
The command <command>fix</command> generates Nix expressions from The command <command>nix-instantiate</command> generates
expressions is Fix's own high-level language. While Nix expressions are (low-level) store expressions from (high-level) Nix expressions.
very primitive and not intended to be written directly, Fix expressions
are quite easy to write.
</para> </para>
</refsect1> </refsect1>
</refentry> </refentry>
<!--
local variables:
sgml-parent-document: ("book.xml" "refentry")
end:
-->

View file

@ -7,12 +7,7 @@
<refsynopsisdiv> <refsynopsisdiv>
<cmdsynopsis> <cmdsynopsis>
<command>nix-store</command> <command>nix-store</command>
<arg rep='repeat'><option>--verbose</option></arg> &opt-common-syn;
<arg rep='repeat'><option>-v</option></arg>
<arg><option>--build-output</option></arg>
<arg><option>-B</option></arg>
<arg><option>--keep-failed</option></arg>
<arg><option>-K</option></arg>
<arg choice='plain'><replaceable>operation</replaceable></arg> <arg choice='plain'><replaceable>operation</replaceable></arg>
<arg rep='repeat'><replaceable>options</replaceable></arg> <arg rep='repeat'><replaceable>options</replaceable></arg>
<arg rep='repeat'><replaceable>arguments</replaceable></arg> <arg rep='repeat'><replaceable>arguments</replaceable></arg>
@ -51,19 +46,7 @@
<variablelist> <variablelist>
&opt-verbose; &opt-common;
<varlistentry>
<term><option>--keep-failed</option> / <option>-K</option></term>
<listitem>
<para>
Specifies that in case of a build failure, the temporary directory
(usually in <filename>/tmp</filename>) in which the build takes
place should not be deleted. The path of the build directory is
printed as an informational message.
</para>
</listitem>
</varlistentry>
</variablelist> </variablelist>

View file

@ -0,0 +1,8 @@
<arg><option>--help</option></arg>
<arg><option>--version</option></arg>
<arg rep='repeat'><option>--verbose</option></arg>
<arg rep='repeat'><option>-v</option></arg>
<arg><option>--build-output</option></arg>
<arg><option>-B</option></arg>
<arg><option>--keep-failed</option></arg>
<arg><option>-K</option></arg>

View file

@ -1,3 +1,23 @@
<varlistentry>
<term><option>--help</option></term>
<listitem>
<para>
Prints out a summary of the command syntax and exits.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--version</option></term>
<listitem>
<para>
Prints out the Nix version number on standard output and exits.
</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><option>--verbose</option> / <option>-v</option></term> <term><option>--verbose</option> / <option>-v</option></term>
<listitem> <listitem>
@ -72,6 +92,7 @@
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><option>--build-output</option> / <option>-B</option></term> <term><option>--build-output</option> / <option>-B</option></term>
<listitem> <listitem>
@ -85,3 +106,17 @@
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><option>--keep-failed</option> / <option>-K</option></term>
<listitem>
<para>
Specifies that in case of a build failure, the temporary
directory (usually in <filename>/tmp</filename>) in which the
build takes place should not be deleted. The path of the build
directory is printed as an informational message.
</para>
</listitem>
</varlistentry>

View file

@ -7,4 +7,5 @@ AM_CXXFLAGS = \
-DNIX_DATA_DIR=\"$(datadir)\" \ -DNIX_DATA_DIR=\"$(datadir)\" \
-DNIX_STATE_DIR=\"$(localstatedir)/nix\" \ -DNIX_STATE_DIR=\"$(localstatedir)/nix\" \
-DNIX_LOG_DIR=\"$(localstatedir)/log/nix\" \ -DNIX_LOG_DIR=\"$(localstatedir)/log/nix\" \
-DNIX_VERSION=\"$(VERSION)\" \
-I.. -I../../externals/inst/include -I../libutil -I../libstore -I.. -I../../externals/inst/include -I../libutil -I../libstore

View file

@ -70,6 +70,9 @@ static void initAndRun(int argc, char * * argv)
else if (arg == "--help") { else if (arg == "--help") {
printHelp(); printHelp();
return; return;
} else if (arg == "--version") {
cout << format("%1% (Nix) %2%") % programId % NIX_VERSION << endl;
return;
} else if (arg == "--keep-failed" || arg == "-K") } else if (arg == "--keep-failed" || arg == "-K")
keepFailed = true; keepFailed = true;
else remaining.push_back(arg); else remaining.push_back(arg);

View file

@ -21,7 +21,7 @@ name `*' may be used to indicate all derivations.
Query types: Query types:
--name: print derivation names (default) --name: print derivation names (default)
--expr / -e: print derivation store expression --expr: print derivation store expression
--status / -s: print installed/present status --status / -s: print installed/present status
Query sources: Query sources:

View file

@ -29,6 +29,7 @@ struct DrvInfo
}; };
typedef map<Path, DrvInfo> DrvInfos; typedef map<Path, DrvInfo> DrvInfos;
typedef vector<DrvInfo> DrvInfoList;
void printHelp() void printHelp()
@ -547,6 +548,12 @@ static void opUninstall(Globals & globals,
} }
static bool cmpDrvByName(const DrvInfo & a, const DrvInfo & b)
{
return a.name < b.name;
}
static void opQuery(Globals & globals, static void opQuery(Globals & globals,
Strings opFlags, Strings opArgs) Strings opFlags, Strings opArgs)
{ {
@ -556,7 +563,7 @@ static void opQuery(Globals & globals,
for (Strings::iterator i = opFlags.begin(); for (Strings::iterator i = opFlags.begin();
i != opFlags.end(); ++i) i != opFlags.end(); ++i)
if (*i == "--name") query = qName; if (*i == "--name") query = qName;
else if (*i == "--expr" || *i == "-e") query = qDrvPath; else if (*i == "--expr") query = qDrvPath;
else if (*i == "--status" || *i == "-s") query = qStatus; else if (*i == "--status" || *i == "-s") query = qStatus;
else if (*i == "--installed") source = sInstalled; else if (*i == "--installed") source = sInstalled;
else if (*i == "--available" || *i == "-a") source = sAvailable; else if (*i == "--available" || *i == "-a") source = sAvailable;
@ -580,19 +587,25 @@ static void opQuery(Globals & globals,
} }
if (opArgs.size() != 0) throw UsageError("no arguments expected"); if (opArgs.size() != 0) throw UsageError("no arguments expected");
/* Sort them by name. */
DrvInfoList drvs2;
for (DrvInfos::iterator i = drvs.begin(); i != drvs.end(); ++i)
drvs2.push_back(i->second);
sort(drvs2.begin(), drvs2.end(), cmpDrvByName);
/* Perform the specified query on the derivations. */ /* Perform the specified query on the derivations. */
switch (query) { switch (query) {
case qName: { case qName: {
for (DrvInfos::iterator i = drvs.begin(); i != drvs.end(); ++i) for (DrvInfoList::iterator i = drvs2.begin(); i != drvs2.end(); ++i)
cout << format("%1%\n") % i->second.name; cout << format("%1%\n") % i->name;
break; break;
} }
case qDrvPath: { case qDrvPath: {
for (DrvInfos::iterator i = drvs.begin(); i != drvs.end(); ++i) for (DrvInfoList::iterator i = drvs2.begin(); i != drvs2.end(); ++i)
cout << format("%1%\n") % i->second.drvPath; cout << format("%1%\n") % i->drvPath;
break; break;
} }
@ -605,14 +618,14 @@ static void opQuery(Globals & globals,
i != installed.end(); ++i) i != installed.end(); ++i)
installedPaths.insert(i->second.outPath); installedPaths.insert(i->second.outPath);
for (DrvInfos::iterator i = drvs.begin(); i != drvs.end(); ++i) { for (DrvInfoList::iterator i = drvs2.begin(); i != drvs2.end(); ++i) {
Paths subs = querySubstitutes(i->second.drvPath); Paths subs = querySubstitutes(i->drvPath);
cout << format("%1%%2%%3% %4%\n") cout << format("%1%%2%%3% %4%\n")
% (installedPaths.find(i->second.outPath) % (installedPaths.find(i->outPath)
!= installedPaths.end() ? 'I' : '-') != installedPaths.end() ? 'I' : '-')
% (isValidPath(i->second.outPath) ? 'P' : '-') % (isValidPath(i->outPath) ? 'P' : '-')
% (subs.size() > 0 ? 'S' : '-') % (subs.size() > 0 ? 'S' : '-')
% i->second.name; % i->name;
} }
break; break;
} }