lix/doc/manual/quick-start/getting-started.xml

108 lines
2.9 KiB
XML
Raw Normal View History

<chapter xmlns="http://docbook.org/ns/docbook"
2014-08-27 16:41:09 +00:00
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
version="5.0"
xml:id="ch-getting-started-nix">
2014-08-27 16:41:09 +00:00
<title>Getting Started with Nix</title>
2014-08-27 16:41:09 +00:00
<para>This tutorial takes you through the basic tasks you might perform when you start using Nix.</para>
<procedure>
2014-08-27 16:41:09 +00:00
<step><para>Install Nix by running the following:
<screen>
2014-04-08 14:28:39 +00:00
$ bash &lt;(curl https://nixos.org/nix/install)
</screen>
2014-04-08 14:28:39 +00:00
This will install Nix in <filename>/nix</filename>. The install script
will create <filename>/nix</filename> using <command>sudo</command>,
so make sure you have sufficient rights. (For other installation
2014-08-27 16:41:09 +00:00
methods, see <xref linkend="chap-installation"/>.)</para></step>
2014-08-27 16:41:09 +00:00
<step><para>See what installable packages are currently available
2007-12-04 11:42:58 +00:00
in the channel:
<screen>
2014-04-08 14:28:39 +00:00
$ nix-env -qa
2004-01-20 15:37:55 +00:00
docbook-xml-4.2
firefox-1.0pre-PR-0.10.1
hello-2.1.1
2004-01-20 15:37:55 +00:00
libxslt-1.1.0
<replaceable>...</replaceable></screen>
2014-08-27 16:41:09 +00:00
</para></step>
2004-01-20 15:37:55 +00:00
2014-08-27 16:41:09 +00:00
<step><para>Install some packages from the channel:
<screen>
2014-04-08 14:28:39 +00:00
$ nix-env -i hello <replaceable>...</replaceable> </screen>
2004-01-20 15:37:55 +00:00
2007-12-04 11:42:58 +00:00
This should download pre-built packages; it should not build them
2014-08-27 16:41:09 +00:00
locally (if it does, something went wrong).</para></step>
2004-01-20 15:37:55 +00:00
2014-08-27 16:41:09 +00:00
<step><para>Test that they work:
2004-01-20 15:37:55 +00:00
<screen>
2004-01-20 15:37:55 +00:00
$ which hello
/home/eelco/.nix-profile/bin/hello
2004-01-20 15:37:55 +00:00
$ hello
Hello, world!
2014-04-08 14:28:39 +00:00
</screen>
2004-01-20 15:37:55 +00:00
2014-08-27 16:41:09 +00:00
</para></step>
2014-08-27 16:41:09 +00:00
<step><para>Uninstall a package:
2004-01-20 15:37:55 +00:00
<screen>
2004-01-20 15:37:55 +00:00
$ nix-env -e hello</screen>
2014-08-27 16:41:09 +00:00
</para></step>
2014-08-27 16:41:09 +00:00
<step><para>To keep up-to-date with the channel, do:
<screen>
2014-04-08 14:28:39 +00:00
$ nix-channel --update nixpkgs
$ nix-env -u '*'</screen>
2007-12-04 11:42:58 +00:00
The latter command will upgrade each installed package for which there
is a “newer” version (as determined by comparing the version
2014-08-27 16:41:09 +00:00
numbers).</para></step>
2004-01-20 15:37:55 +00:00
2014-08-27 16:41:09 +00:00
<step><para>You can also install specific packages directly from
2006-09-29 11:03:16 +00:00
your web browser. For instance, you can go to <link
2012-05-11 21:39:06 +00:00
xlink:href="http://hydra.nixos.org/jobset/nixpkgs/trunk/channel/latest"
/> and click on any link for the individual packages for your
platform. Associate <literal>application/nix-package</literal> with
the program <command>nix-install-package</command>. A window should
2006-09-29 11:03:16 +00:00
appear asking you whether its okay to install the package. Say
<literal>Y</literal>. The package and all its dependencies will be
2014-08-27 16:41:09 +00:00
installed.</para></step>
2006-09-29 11:03:16 +00:00
2014-08-27 16:41:09 +00:00
<step><para>If you're unhappy with the result of a
2007-12-04 11:42:58 +00:00
<command>nix-env</command> action (e.g., an upgraded package turned
out not to work properly), you can go back:
2004-01-20 15:37:55 +00:00
<screen>
$ nix-env --rollback</screen>
2004-01-20 15:37:55 +00:00
2014-08-27 16:41:09 +00:00
</para></step>
2004-01-20 15:37:55 +00:00
2014-08-27 16:41:09 +00:00
<step><para>You should periodically run the Nix garbage collector
to get rid of unused packages, since uninstalls or upgrades don't
2004-11-14 00:24:57 +00:00
actually delete them:
2004-01-20 15:37:55 +00:00
<screen>
$ nix-collect-garbage -d</screen>
2004-01-20 15:37:55 +00:00
<!--
The first command deletes old “generations” of your profile (making
2007-12-04 11:42:58 +00:00
rollbacks impossible, but also making the packages in those old
generations available for garbage collection), while the second
command actually deletes them.-->
2014-08-27 16:41:09 +00:00
</para></step>
2004-01-20 15:37:55 +00:00
2014-08-27 16:41:09 +00:00
</procedure>
2004-01-20 15:37:55 +00:00
2014-08-27 16:41:09 +00:00
</chapter>