2020-07-22 14:51:11 +03:00
|
|
|
# Quick Start
|
|
|
|
|
|
|
|
This chapter is for impatient people who don't like reading
|
|
|
|
documentation. For more in-depth information you are kindly referred
|
|
|
|
to subsequent chapters.
|
|
|
|
|
2023-01-16 21:35:12 +02:00
|
|
|
1. Install Nix by running the following:
|
2020-07-22 14:51:11 +03:00
|
|
|
|
2020-07-31 16:43:25 +03:00
|
|
|
```console
|
2023-02-08 00:32:27 +02:00
|
|
|
$ curl -L https://nixos.org/nix/install | sh
|
2020-07-31 16:43:25 +03:00
|
|
|
```
|
2020-07-22 14:51:11 +03:00
|
|
|
|
2023-01-16 21:35:12 +02:00
|
|
|
The install script will use `sudo`, so make sure you have sufficient rights.
|
|
|
|
On Linux, `--daemon` can be omitted for a single-user install.
|
|
|
|
|
|
|
|
For other installation methods, see [here](installation/installation.md).
|
2020-07-22 14:51:11 +03:00
|
|
|
|
|
|
|
1. See what installable packages are currently available in the
|
|
|
|
channel:
|
|
|
|
|
2020-07-31 16:43:25 +03:00
|
|
|
```console
|
2021-11-17 17:30:39 +02:00
|
|
|
$ nix-env -qaP
|
|
|
|
nixpkgs.docbook_xml_dtd_43 docbook-xml-4.3
|
|
|
|
nixpkgs.docbook_xml_dtd_45 docbook-xml-4.5
|
|
|
|
nixpkgs.firefox firefox-33.0.2
|
|
|
|
nixpkgs.hello hello-2.9
|
|
|
|
nixpkgs.libxslt libxslt-1.1.28
|
2020-07-31 16:43:25 +03:00
|
|
|
…
|
|
|
|
```
|
2020-07-22 14:51:11 +03:00
|
|
|
|
|
|
|
1. Install some packages from the channel:
|
|
|
|
|
2020-07-31 16:43:25 +03:00
|
|
|
```console
|
2021-11-17 17:30:39 +02:00
|
|
|
$ nix-env -iA nixpkgs.hello
|
2020-07-31 16:43:25 +03:00
|
|
|
```
|
2020-07-22 14:51:11 +03:00
|
|
|
|
|
|
|
This should download pre-built packages; it should not build them
|
|
|
|
locally (if it does, something went wrong).
|
|
|
|
|
|
|
|
1. Test that they work:
|
|
|
|
|
2020-07-31 16:43:25 +03:00
|
|
|
```console
|
|
|
|
$ which hello
|
|
|
|
/home/eelco/.nix-profile/bin/hello
|
|
|
|
$ hello
|
|
|
|
Hello, world!
|
|
|
|
```
|
2020-07-22 14:51:11 +03:00
|
|
|
|
|
|
|
1. Uninstall a package:
|
|
|
|
|
2020-07-31 16:43:25 +03:00
|
|
|
```console
|
|
|
|
$ nix-env -e hello
|
|
|
|
```
|
2020-07-22 14:51:11 +03:00
|
|
|
|
|
|
|
1. You can also test a package without installing it:
|
|
|
|
|
2020-07-31 16:43:25 +03:00
|
|
|
```console
|
|
|
|
$ nix-shell -p hello
|
|
|
|
```
|
2020-07-22 14:51:11 +03:00
|
|
|
|
|
|
|
This builds or downloads GNU Hello and its dependencies, then drops
|
|
|
|
you into a Bash shell where the `hello` command is present, all
|
|
|
|
without affecting your normal environment:
|
|
|
|
|
2020-07-31 16:43:25 +03:00
|
|
|
```console
|
|
|
|
[nix-shell:~]$ hello
|
|
|
|
Hello, world!
|
2020-07-22 14:51:11 +03:00
|
|
|
|
2020-07-31 16:43:25 +03:00
|
|
|
[nix-shell:~]$ exit
|
2020-07-22 14:51:11 +03:00
|
|
|
|
2020-07-31 16:43:25 +03:00
|
|
|
$ hello
|
|
|
|
hello: command not found
|
|
|
|
```
|
2020-07-22 14:51:11 +03:00
|
|
|
|
|
|
|
1. To keep up-to-date with the channel, do:
|
|
|
|
|
2020-07-31 16:43:25 +03:00
|
|
|
```console
|
|
|
|
$ nix-channel --update nixpkgs
|
|
|
|
$ nix-env -u '*'
|
|
|
|
```
|
2020-07-22 14:51:11 +03:00
|
|
|
|
|
|
|
The latter command will upgrade each installed package for which
|
|
|
|
there is a “newer” version (as determined by comparing the version
|
|
|
|
numbers).
|
|
|
|
|
|
|
|
1. If you're unhappy with the result of a `nix-env` action (e.g., an
|
|
|
|
upgraded package turned out not to work properly), you can go back:
|
|
|
|
|
2020-07-31 16:43:25 +03:00
|
|
|
```console
|
|
|
|
$ nix-env --rollback
|
|
|
|
```
|
2020-07-22 14:51:11 +03:00
|
|
|
|
|
|
|
1. You should periodically run the Nix garbage collector to get rid of
|
|
|
|
unused packages, since uninstalls or upgrades don't actually delete
|
|
|
|
them:
|
|
|
|
|
2020-07-31 16:43:25 +03:00
|
|
|
```console
|
|
|
|
$ nix-collect-garbage -d
|
|
|
|
```
|