|
4 | 4 |
|
5 | 5 | 
|
6 | 6 |
|
7 |
| -Setting up a new machine is time-consuming, and becomes complicated when it needs to be done remotely. If you're installing NixOS, the **nixos-anywhere** (formerly known as **nixos-remote**) tool allows you to pre-configure the whole process including: |
| 7 | +Setting up a new machine is time-consuming, and becomes complicated when it |
| 8 | +needs to be done remotely. If you're installing NixOS, the **nixos-anywhere** |
| 9 | +(formerly known as **nixos-remote**) tool allows you to pre-configure the whole |
| 10 | +process including: |
8 | 11 |
|
9 | 12 | - Disk partitioning and formatting
|
10 | 13 | - Configuring and installing either NixOS or SrvOS
|
11 | 14 | - Installing additional files and software
|
12 | 15 |
|
13 |
| -You can then initiate an unattended installation with a single CLI command. Since **nixos-anywhere** can access the new machine using SSH, it's ideal for remote installations. |
| 16 | +You can then initiate an unattended installation with a single CLI command. |
| 17 | +Since **nixos-anywhere** can access the new machine using SSH, it's ideal for |
| 18 | +remote installations. |
14 | 19 |
|
15 |
| -Once you have initiated the command, there is no need to 'babysit' the installation. It all happens automatically. |
| 20 | +Once you have initiated the command, there is no need to 'babysit' the |
| 21 | +installation. It all happens automatically. |
16 | 22 |
|
17 |
| -You can use the stored configuration to repeat the same installation if you need to. |
| 23 | +You can use the stored configuration to repeat the same installation if you need |
| 24 | +to. |
18 | 25 |
|
19 | 26 | ## Overview
|
20 | 27 |
|
21 |
| -If you have machines on a mix of platforms, you'll need a common installation solution that works anywhere. **nixos-anywhere** is ideal in this situation. |
| 28 | +If you have machines on a mix of platforms, you'll need a common installation |
| 29 | +solution that works anywhere. **nixos-anywhere** is ideal in this situation. |
22 | 30 |
|
23 |
| -**nixos-anywhere** can be used equally well for cloud servers, bare metal servers such as Hetzner, and local servers accessible via a LAN. You can create standard configurations, and use the same configuration to create identical servers anywhere. |
| 31 | +**nixos-anywhere** can be used equally well for cloud servers, bare metal |
| 32 | +servers such as Hetzner, and local servers accessible via a LAN. You can create |
| 33 | +standard configurations, and use the same configuration to create identical |
| 34 | +servers anywhere. |
24 | 35 |
|
25 |
| -You first create Nix configurations to specify partitioning, formatting and NixOS configurations. Further options can be controlled by a flake and by run-time switches. |
| 36 | +You first create Nix configurations to specify partitioning, formatting and |
| 37 | +NixOS configurations. Further options can be controlled by a flake and by |
| 38 | +run-time switches. |
26 | 39 |
|
27 | 40 | Once the configuration has been created, a single command will:
|
28 | 41 |
|
29 | 42 | - Connect to the remote server via SSH
|
30 |
| -- Detect whether a NixOS installer is present; if not, it will use the Linux `kexec` tool to boot into a Nixos installer. |
31 |
| -- Use the [disko](https://github.com/nix-community/disko) tool to partition and format the hard drive |
| 43 | +- Detect whether a NixOS installer is present; if not, it will use the Linux |
| 44 | + `kexec` tool to boot into a Nixos installer. |
| 45 | +- Use the [disko](https://github.com/nix-community/disko) tool to partition and |
| 46 | + format the hard drive |
32 | 47 | - Install NixOS
|
33 | 48 | - Optionally install any Nix packages and other software required.
|
34 | 49 | - Optionally copy additional files to the new machine
|
35 | 50 |
|
36 |
| -It's also possible to use **nixos-anywhere** to simplify the installation on a machine that has no current operating system, first booting from a NixOS installer image. This feature is described in the [how-to guide](./docs/how_to.md#installing-on-a-machine-with-no-operating-system). It's useful because you can pre-configure your required software and preferences, and build the new machine with a single command. |
| 51 | +It's also possible to use **nixos-anywhere** to simplify the installation on a |
| 52 | +machine that has no current operating system, first booting from a NixOS |
| 53 | +installer image. This feature is described in the |
| 54 | +[how-to guide](./docs/how_to.md#installing-on-a-machine-with-no-operating-system). |
| 55 | +It's useful because you can pre-configure your required software and |
| 56 | +preferences, and build the new machine with a single command. |
37 | 57 |
|
38 |
| -**Important Note:** Never use a production server as the target. It will be completely overwritten and all data lost. This tool should only be used for commissioning a new computer or repurposing an old machine once all important data has been migrated. |
| 58 | +**Important Note:** Never use a production server as the target. It will be |
| 59 | +completely overwritten and all data lost. This tool should only be used for |
| 60 | +commissioning a new computer or repurposing an old machine once all important |
| 61 | +data has been migrated. |
39 | 62 |
|
40 | 63 | ## Prerequisites
|
41 | 64 |
|
42 | 65 | - Source Machine:
|
43 | 66 | - - Can be any Linux machine with Nix installed, or a NixOS machine.
|
44 | 67 | - Target Machine:
|
45 | 68 |
|
46 |
| - - Unless you're using the option to boot from a NixOS installer image, or providing your own `kexec` image, it must be running x86-64 Linux with kexec support. Most x86_64 Linux systems do have kexec support. By providing your own [image](./docs/how_to.md#using-your-own-kexec-image) you can also perform kexec for other architectures eg aarch64 |
| 69 | + - Unless you're using the option to boot from a NixOS installer image, or |
| 70 | + providing your own `kexec` image, it must be running x86-64 Linux with kexec |
| 71 | + support. Most x86_64 Linux systems do have kexec support. By providing your |
| 72 | + own [image](./docs/how_to.md#using-your-own-kexec-image) you can also |
| 73 | + perform kexec for other architectures eg aarch64 |
47 | 74 | - Must have at least 1.5 GB of RAM, excluding swap.
|
48 | 75 |
|
49 | 76 | ## How to use nixos-anywhere
|
50 | 77 |
|
51 |
| -Here’s a quick summary of how to use **nixos-anywhere**. You can find more information in the [product documentation](./docs). |
| 78 | +Here’s a quick summary of how to use **nixos-anywhere**. You can find more |
| 79 | +information in the [product documentation](./docs). |
52 | 80 |
|
53 |
| -The tool doesn't need to be installed, since it can be run directly from this repository. |
| 81 | +The tool doesn't need to be installed, since it can be run directly from this |
| 82 | +repository. |
54 | 83 |
|
55 |
| -First create a repo that includes the disk configuration and a [flake](https://nixos.wiki/wiki/Flakes) to configure your options. This example assumes that flakes have been enabled on your source machine. |
| 84 | +First create a repo that includes the disk configuration and a |
| 85 | +[flake](https://nixos.wiki/wiki/Flakes) to configure your options. This example |
| 86 | +assumes that flakes have been enabled on your source machine. |
56 | 87 |
|
57 | 88 | Here’s an example of a simple disk configuration:
|
58 | 89 |
|
@@ -104,7 +135,10 @@ Here’s an example of a simple disk configuration:
|
104 | 135 | }
|
105 | 136 | ```
|
106 | 137 |
|
107 |
| -The [disko repository](https://github.com/nix-community/disko/tree/master/example) has several examples of disk configurations. You can adapt them to our own needs. |
| 138 | +The |
| 139 | +[disko repository](https://github.com/nix-community/disko/tree/master/example) |
| 140 | +has several examples of disk configurations. You can adapt them to our own |
| 141 | +needs. |
108 | 142 |
|
109 | 143 | A simple flake may look like this:
|
110 | 144 |
|
@@ -149,40 +183,54 @@ A simple flake may look like this:
|
149 | 183 | }
|
150 | 184 | ```
|
151 | 185 |
|
152 |
| -Once you’ve created the disk configuration and the flake, you can run the tool with a single nix command, which may look like this: |
| 186 | +Once you’ve created the disk configuration and the flake, you can run the tool |
| 187 | +with a single nix command, which may look like this: |
153 | 188 |
|
154 | 189 | ```
|
155 | 190 | nix run github:numtide/nixos-anywhere -- --flake github:JillThornhill/flakes-example#hetzner-cloud root@135.181.254.201
|
156 | 191 | ```
|
157 | 192 |
|
158 |
| -Note that this command references the URL of your flake, in this case github:JillThornhill/flakes-example, together with the name of the system #hetzner-cloud, as highlighted by the comment in the sample flake. |
| 193 | +Note that this command references the URL of your flake, in this case |
| 194 | +github:JillThornhill/flakes-example, together with the name of the system |
| 195 | +#hetzner-cloud, as highlighted by the comment in the sample flake. |
159 | 196 |
|
160 |
| -The [Quickstart Guide](./docs/Quickstart.md) gives more information on how to run **nixos-anywhere** in its simplest form. For more specific instructions to suit individual requirements, see the [How To Guide](./docs/how_to.md). |
| 197 | +The [Quickstart Guide](./docs/Quickstart.md) gives more information on how to |
| 198 | +run **nixos-anywhere** in its simplest form. For more specific instructions to |
| 199 | +suit individual requirements, see the [How To Guide](./docs/how_to.md). |
161 | 200 |
|
162 | 201 | # Further Reading
|
163 | 202 |
|
164 |
| -@tfc has written a walkthrough on how use **nixos-anywhere** to bootstrap hetzner cloud servers as well as dedicated machines on his [blog](https://galowicz.de/2023/04/05/single-command-server-bootstrap/): |
| 203 | +@tfc has written a walkthrough on how use **nixos-anywhere** to bootstrap |
| 204 | +hetzner cloud servers as well as dedicated machines on his |
| 205 | +[blog](https://galowicz.de/2023/04/05/single-command-server-bootstrap/): |
165 | 206 |
|
166 | 207 | ## Related Tools
|
167 | 208 |
|
168 |
| -**nixos-anywhere** makes use of the [disko](https://github.com/nix-community/disko) tool to handle the partitioning and formatting of the disks. |
| 209 | +**nixos-anywhere** makes use of the |
| 210 | +[disko](https://github.com/nix-community/disko) tool to handle the partitioning |
| 211 | +and formatting of the disks. |
169 | 212 |
|
170 | 213 | ## Licensing and Contribution details
|
171 | 214 |
|
172 |
| -This software is provided free under the [MIT Licence](https://opensource.org/licenses/MIT). |
| 215 | +This software is provided free under the |
| 216 | +[MIT Licence](https://opensource.org/licenses/MIT). |
173 | 217 |
|
174 |
| -If you would like to become a contributor, please see our [contribution guidelines.](https://github.com/numtide/docs/contribution-guidelines.md) |
| 218 | +If you would like to become a contributor, please see our |
| 219 | +[contribution guidelines.](https://github.com/numtide/docs/contribution-guidelines.md) |
175 | 220 |
|
176 | 221 | ---
|
177 | 222 |
|
178 |
| -This project is supported by [Numtide](https://numtide.com/).  |
| 223 | +This project is supported by [Numtide](https://numtide.com/). |
| 224 | +  |
179 | 225 |
|
180 |
| -We are a team of independent freelancers that love open source. We help our customers make their project lifecycles more efficient by: |
| 226 | +We are a team of independent freelancers that love open source. We help our |
| 227 | +customers make their project lifecycles more efficient by: |
181 | 228 |
|
182 | 229 | - Providing and supporting useful tools such as this one
|
183 | 230 | - Building and deploying infrastructure, and offering dedicated DevOps support
|
184 | 231 | - Building their in-house Nix skills, and integrating Nix with their workflows
|
185 | 232 | - Developing additional features and tools
|
186 | 233 | - Carrying out custom research and development.
|
187 | 234 |
|
188 |
| -[Contact us](https://numtide.com/contact) if you have a project in mind, or if you need help with any of our supported tools, including this one. We'd love to |
| 235 | +[Contact us](https://numtide.com/contact) if you have a project in mind, or if |
| 236 | +you need help with any of our supported tools, including this one. We'd love to |
0 commit comments