ALPHA: wire is a tool to deploy nixos systems
wire.althaea.zone/
1---
2comment: true
3title: Apply your Config
4description: How to apply a node with wire.
5---
6
7# {{ $frontmatter.title }}
8
9{{ $frontmatter.description }}
10
11## What does it mean to 'apply'?
12
13Once you have created a hive, you can now "apply" your
14configuration to nodes in your hive. Simply, "applying" is the term used by wire to describe **deploying the
15config**.
16
17::: info
18Applying a node typically involves pushing keys,
19evaluating the node's NixOS system, building the node's NixOS system, and running
20`switch-to-configuration`, depending on which specific goal is used.
21:::
22
23The simplest way to apply is simply running:
24
25```sh
26$ wire apply switch
27```
28
29Which will `switch` to each node's NixOS system in your hive and push
30secrets (the equivalent to `nixos-rebuild`'s `nixos-rebuild switch`).
31
32::: details Apply Goal Flowchart
33The following is an illustrative flowchart of how each step in the apply execution is ran.
34
35Depending on the specific goal certain steps will not run, for example the
36Switch to Configuration step will never run if the goal is `build`.
37
38```mermaid
39flowchart TD
40 A(Test Connection) --> |IP / Hostname| B(Push Keys)
41
42 C(Evaluate NixOS System)
43
44 B --> C
45 C -->|.drv Path| local
46 C -->|.drv Path| remote
47
48 subgraph remote[Remote Node]
49 D(Push To Node)
50 D --> E(Build NixOS System)
51 E -->|Built System| H(Push To Node)
52 end
53
54 subgraph local[Local Node]
55 direction RL
56 G(Build NixOS System Locally)
57 end
58
59 G --> F(Switch To Configuration)
60 H --> F
61```
62
63:::
64
65## Apply goals
66
67`wire apply` accepts a goal, which include verbs which will be familiar to
68`nixos-rebuild` users such as `switch`, `boot`, and `test`, alongside additional verbs
69like `keys` and `push`.
70
71### `wire apply keys`
72
73wire will push all deployment keys to nodes, and do nothing else. While running
74this goal, option
75[`deployment.keys.<name>.uploadAt`](/reference/module#deployment-keys-name-uploadat)
76has no effect and all keys will be pushed. Read [the secret management guide](./keys)
77to learn more about wire deployment keys.
78
79### `wire apply push`
80
81wire will "push" (equivalent to [`nix
82copy`](https://nix.dev/manual/nix/2.18/command-ref/new-cli/nix3-copy)) the
83`.drv` file that can produce the node's NixOS system when built.
84
85### `wire apply build`
86
87Sister to `wire apply push`, wire will build the
88node's NixOS system and ensure the output path exists on the node. Depending on
89[`deployment.buildOnTarget`](/reference/module#deployment-buildontarget), the
90`.drv` file may be built on the machine invoking wire or the node itself.
91
92### `wire apply [switch|boot|test|dry-activate]`
93
94Type `wire apply --help` or
95[read the reference](../reference/cli#wire-apply) to read more.
96
97## Applying locally
98
99If `deployment.allowLocalDeployment` is `true`, and the machine invoking wire's
100host name is equivalent to a node's name, wire will apply that node to the local
101machine. Goals like `push` and `build`, wont actually "push" anything as
102the paths already exists on the local machine.
103
104When applying to your local machine, wire can interactively run `sudo`!
105wire will prompt for your password, meaning wire can be ran as any user in
106the `wheel` group.
107
108## Applying specific nodes
109
110Use the `--on` argument to specify which nodes in your hive to apply:
111
112```sh
113$ wire apply --on node-a
114```
115
116Further examples, including how you can utilise tags, can be found on the [Targeting Nodes](./targeting) page.