Skip to content

Commit 6d9266f

Browse files
fricklerhandwerkmergify[bot]
authored andcommitted
docs: simplify non-flakes instructions
1 parent 3b3c600 commit 6d9266f

File tree

1 file changed

+22
-32
lines changed

1 file changed

+22
-32
lines changed

docs/howtos/use-without-flakes.md

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,39 @@
11
# Use without flakes
22

3-
While `nixos-anywhere` is designed to work optimally with Nix Flakes, it also
4-
supports the traditional approach without flakes. This document outlines how to
5-
use `nixos-anywhere` without relying on flakes. You will need to
6-
[import the disko nixos module](https://github.com/nix-community/disko/blob/master/docs/HowTo.md#installing-nixos-module)
3+
First,
4+
[import the disko NixOS module](https://github.com/nix-community/disko/blob/master/docs/HowTo.md#installing-nixos-module)
75
in your NixOS configuration and define disko devices as described in the
86
[examples](https://github.com/nix-community/disko/tree/master/example).
97

10-
## Generate Required Store Paths
11-
12-
Before you can use `nixos-anywhere` without flakes, you'll need to manually
13-
generate the paths for the NixOS system toplevel and disk image. The paths are
14-
generated using `nix-build` and are necessary for executing `nixos-anywhere`.
15-
16-
### Generating Disk Image without Dependencies:
8+
Let's assume that your NixOS configuration lives in `configuration.nix` and your
9+
target machine is called `machine`.
10+
11+
```nix
12+
# configuration.nix
13+
{
14+
pkgs ? import (fetchTarball channel:nixos-24.05) {};
15+
}:
16+
{
17+
config = { config, pkgs, ... }: { /* ... */ };
18+
machine = pkgs.nixos config;
19+
}
20+
```
1721

18-
To generate the disk image without dependencies, execute:
22+
Generate the disk formatting script:
1923

2024
```bash
21-
nix-build -I nixos-config=/etc/nixos/configuration.nix -E '(import <nixpkgs/nixos> {}).config.system.build.diskoNoDeps'
25+
disko=$(nix-build configuration.nix -A machine.config.system.build.disko' --no-out-path)
2226
```
2327
24-
This will output a script path in `/nix/store` that will format your disk. Make
25-
note of this path for later use.
26-
27-
### Generating NixOS System Toplevel:
28-
29-
Execute the following command to generate the store path for the NixOS system
30-
toplevel:
28+
Generate the store path that includes all the software and configurations for
29+
the NixOS system:
3130
3231
```bash
33-
nix-build -I nixos-config=/etc/nixos/configuration.nix -E '(import <nixpkgs/nixos> {}).config.system.build.toplevel'
32+
nixos=$(nix-build configuration.nix -A machine.config.system.build.toplevel' --no-out-path)
3433
```
3534

36-
This will output a path in `/nix/store` that corresponds to the system toplevel,
37-
which includes all the software and configurations for the system. Keep this
38-
path handy as well.
39-
40-
## Running NixOS-Anywhere
41-
42-
With both paths in hand, you can execute `nixos-anywhere` as follows:
35+
Run `nixos-anywhere` as follows:
4336

4437
```bash
45-
nixos-anywhere --store-paths /nix/store/[your-disk-image-path] /nix/store/[your-toplevel-path]
38+
nixos-anywhere --store-paths $disko $nixos root@machine
4639
```
47-
48-
Replace `[your-disk-image-path]` and `[your-toplevel-path]` with the
49-
corresponding store paths you generated earlier.

0 commit comments

Comments
 (0)