Skip to content

Commit

Permalink
manual: add nixos-rebuild build-image section
Browse files Browse the repository at this point in the history
  • Loading branch information
phaer committed Dec 15, 2024
1 parent 1d0a29c commit b79f1c3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Building Images with `nixos-rebuild build-image` {#sec-image-nixos-rebuild-build-image}

Nixpkgs contains a variety of modules to build custom images for different virtualization platforms and cloud providers, such as e.g. `amazon-image.nix` and `proxmox-lxc.nix`.

While those can be imported individually, `system.build.images` provides an attribute set mapping variant names to image derivations. Available variants are defined - end extendable - in `image.modules`, an attribute set mapping variant names to a list of NixOS modules.

All of those images can be built via both, their `system.build.image` attribute, and the CLI `nixos-rebuild build-image`. To build i.e. an Amazon image from your existing NixOS configuration:

```ShellSession
$ nixos-rebuild build-image --image-variant amazon
$ ls result
nixos-image-amazon-25.05pre-git-x86_64-linux.vhd nix-support
```

To get a list of all variants available, run `nixos-rebuild build-image` without arguments.

4 changes: 1 addition & 3 deletions nixos/doc/manual/installation/building-nixos.chapter.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Building a NixOS (Live) ISO {#sec-building-image}

Default live installer configurations are available inside `nixos/modules/installer/cd-dvd`.
For building other system images, [nixos-generators] is a good place to start looking at.
For building other system images, see [Building Images with `nixos-rebuild build-image`](#sec-image-nixos-rebuild-build-image).

You have two options:

Expand All @@ -14,8 +14,6 @@ on which they immediately depend in order to work correctly.
However, if you are confident, you can opt to override those
enforced values with `mkForce`.

[nixos-generators]: https://github.com/nix-community/nixos-generators

## Practical Instructions {#sec-building-image-instructions}

To build an ISO image for the channel `nixos-unstable`:
Expand Down
1 change: 1 addition & 0 deletions nixos/doc/manual/installation/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ installing.chapter.md
changing-config.chapter.md
upgrading.chapter.md
building-nixos.chapter.md
building-images-via-nixos-rebuild-build-image.chapter.md
building-images-via-systemd-repart.chapter.md
```
3 changes: 3 additions & 0 deletions nixos/doc/manual/redirects.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@
"sec-building-image-tech-notes": [
"index.html#sec-building-image-tech-notes"
],
"sec-image-nixos-rebuild-build-image": [
"index.html#sec-image-nixos-rebuild-build-image"
],
"sec-image-repart": [
"index.html#sec-image-repart"
],
Expand Down

0 comments on commit b79f1c3

Please sign in to comment.