manual: add nixos-rebuild build-image section

This commit is contained in:
phaer 2024-11-26 12:21:05 +01:00
parent 1d0a29c279
commit b79f1c3c99
4 changed files with 21 additions and 3 deletions

View file

@ -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.

View file

@ -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:
@ -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`:

View file

@ -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
```

View file

@ -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"
],