1---
2last_modified_on: "2020-07-13"
3title: Install Vector via Nix
4sidebar_label: Nix
5description: Install Vector through the Nix package manager
6---
7
8import Alert from '@site/src/components/Alert';
9import CodeExplanation from '@site/src/components/CodeExplanation';
10import ConfigExample from '@site/src/components/ConfigExample';
11import DaemonDiagram from '@site/src/components/DaemonDiagram';
12import Jump from '@site/src/components/Jump';
13import Steps from '@site/src/components/Steps';
14import Tabs from '@theme/Tabs';
15import TabItem from '@theme/TabItem';
16
17Vector can be installed through the [Nix package manager][urls.nix] via
18[Vector's Nix package][urls.vector_nix_package]. This package manager is
19generally used on [NixOS][urls.nixos].
20
21<Alert type="warning">
22
23Because Vector must be manually updated on Nix, new Vector releases will be
24delayed. Generally new Vector releases are made available within a few days.
25
26</Alert>
27
28<!--
29     THIS FILE IS AUTOGENERATED!
30
31     To make changes please edit the template located at:
32
33     website/docs/setup/installation/package-managers/nix.md.erb
34-->
35
36## Install
37
38<Tabs
39  block={true}
40  defaultValue="daemon"
41  values={[{"label":"As a Daemon","value":"daemon"}]}>
42<TabItem value="daemon">
43
44The [daemon deployment strategy][docs.strategies#daemon] is designed for data
45collection on a single host. Vector runs in the background, in its own process,
46collecting _all_ data for that host.
47Typically data is collected from a process manager, such as Journald via
48Vector's [`journald` source][docs.sources.journald], but can be collected
49through any of Vector's [sources][docs.sources].
50The following diagram demonstrates how it works.
51
52<DaemonDiagram
53  platformName={null}
54  sourceName={null}
55  sinkName={null} />
56
57---
58
59<Tabs
60  centered={true}
61  className={"rounded"}
62  defaultValue={"nix"}
63  placeholder="Please choose an installation method..."
64  select={false}
65  size={null}
66  values={[{"group":"Package managers","label":"Nix","value":"nix"}]}>
67<TabItem value="nix">
68
69<Steps headingDepth={3}>
70
711.  ### Install Vector
72
73    ```bash
74    nix-env --file https://github.com/NixOS/nixpkgs/archive/master.tar.gz --install --attr vector
75    ```
76
77    <CodeExplanation>
78
79    * The `--file` flag ensures that you're installing the latest stable version
80      of Vector (0.10.0).
81    * The `--attr` improves installation speed.
82
83    </CodeExplanation>
84
85    [Looking for a specific version?][docs.package_managers.nix#versions]
86
872.  ### Configure Vector
88
89    <ConfigExample
90      format="toml"
91      path={"/etc/vector/vector.toml"}
92      sourceName={"journald"}
93      sinkName={null} />
94
953.  ### Start Vector
96
97    ```bash
98    vector --config /etc/vector/vector.toml
99    ```
100
101    <CodeExplanation>
102
103    * `vector` is placed in your `$PATH`.
104    * You must create a [Vector configuration file][docs.configuration] to
105      successfully start Vector.
106
107    </CodeExplanation>
108
109</Steps>
110
111</TabItem>
112</Tabs>
113</TabItem>
114</Tabs>
115
116## Configuring
117
118The [Vector nix package][urls.vector_nix_package] does not install any
119configuration files by default. You'll need to create a
120[Vector configuration file][docs.configuration] and pass it to Vector via the
121`--config` flag when [starting][docs.process-management#starting] Vector.
122
123## Deploying
124
125How you deploy Vector is largely dependent on your use case and environment.
126Please see the [deployment section][docs.deployment] for more info on how to
127deploy Vector.
128
129## Administering
130
131The Vector nix package does not use Systemd by default, but Vector does provide
132a [Systemd service file][urls.vector_systemd_file] that you can use as a
133starting point. How you manage the Vector process is up to you, and the
134process administration section covers how to do this:
135
136<Jump to="/docs/administration/">Administration</Jump>
137
138## Uninstalling
139
140```bash
141nix-env --uninstall vector
142```
143
144## Updating
145
146```bash
147nix-env --file https://github.com/NixOS/nixpkgs/archive/master.tar.gz --upgrade vector
148```
149
150## Package
151
152### Architectures
153
154Vector's Nix packages only support the X86_64 architecture.
155
156### Versions
157
158Installing previous versions of Vector through `nix` is possible, but not
159straightforward. For example, installing Vector `0.7.1` can be achieved with
160the following command:
161
162```bash
163nix-env --file https://github.com/NixOS/nixpkgs/archive/20bbe6cba68fb9d37b5d0e373b6180dce2961e0d.tar.gz --install --attr vector
164```
165
166`20bbe6...` represents the commit sha for the `0.7.1` on the
167[nix package repo][urls.vector_nix_package].
168
169#### Listing Versions & Commit SHAs
170
171For situations that required automated retrieval, we've thrown thogether this
172handy Ruby function that will list the Vector versions and their commit sha:
173
174```ruby
175require "net/http"
176require "json"
177
178# Returns a hash mapping Vector versions to commits in `nixpkgs/nixos` repository
179def nix_versions
180  nixpkgs_repo = "nixos/nixpkgs"
181  commits_url = "https://api.github.com/repos/#{nixpkgs_repo}/commits?path=pkgs/tools/misc/vector"
182
183  response = Net::HTTP.get URI(commits_url)
184  items = JSON.parse response
185
186  versions = {}
187  for item in items do
188    match = item["commit"]["message"].match "^vector:.*(\\d+\.\\d+\.\\d+)$"
189    if match
190      version = match[1]
191      versions[version] = item["sha"]
192    end
193  end
194
195  versions
196end
197```
198
199### Source Files
200
201Vector's Nix source files are located in the
202[Nix repo][urls.vector_nix_package].
203
204[docs.configuration]: /docs/setup/configuration/
205[docs.deployment]: /docs/setup/deployment/
206[docs.package_managers.nix#versions]: /docs/setup/installation/package-managers/nix/#versions
207[docs.process-management#starting]: /docs/administration/process-management/#starting
208[docs.sources.journald]: /docs/reference/sources/journald/
209[docs.sources]: /docs/reference/sources/
210[docs.strategies#daemon]: /docs/setup/deployment/strategies/#daemon
211[urls.nix]: https://nixos.org/nix/
212[urls.nixos]: https://nixos.org/
213[urls.vector_nix_package]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/tools/misc/vector/default.nix
214[urls.vector_systemd_file]: https://github.com/timberio/vector/blob/master/distribution/systemd/vector.service
215