2019-01-17 17:18:00 +03:00
|
|
|
# nixos-generators - one config, multiple formats
|
|
|
|
|
|
|
|
The nixos-generators project allows to take the same NixOS configuration, and
|
|
|
|
generate outputs for different target formats.
|
|
|
|
|
2019-02-01 01:06:29 +03:00
|
|
|
Just put your stuff into the configuration.nix and then call one of the image builders.
|
2018-04-28 13:01:45 +03:00
|
|
|
|
|
|
|
for example:
|
|
|
|
```
|
2019-08-19 17:07:08 +03:00
|
|
|
nixos-generate -f iso
|
2018-04-28 13:01:45 +03:00
|
|
|
```
|
2018-05-17 23:46:25 +03:00
|
|
|
or
|
2019-01-17 17:18:00 +03:00
|
|
|
|
2018-05-17 23:46:25 +03:00
|
|
|
```
|
2019-08-19 17:07:08 +03:00
|
|
|
nixos-generate -f iso -c /etc/nixos/configuration.nix
|
2018-05-17 23:46:25 +03:00
|
|
|
```
|
2018-04-28 13:01:45 +03:00
|
|
|
|
2019-01-17 17:18:00 +03:00
|
|
|
it echoes the path to a iso image, which you then can flash onto an usb-stick
|
|
|
|
or mount & boot in a virtual machine.
|
2018-04-28 13:01:45 +03:00
|
|
|
|
2019-01-22 01:47:08 +03:00
|
|
|
# Installation
|
|
|
|
|
|
|
|
nixos-generators can be installed from source into the user profile like this:
|
|
|
|
|
|
|
|
```console
|
2019-08-19 17:07:08 +03:00
|
|
|
nix-env -f https://github.com/nix-community/nixos-generators/archive/master.tar.gz -i
|
2019-01-22 01:47:08 +03:00
|
|
|
```
|
|
|
|
|
2019-01-17 17:18:00 +03:00
|
|
|
## Supported formats
|
2018-04-28 13:01:45 +03:00
|
|
|
|
2019-01-17 17:18:00 +03:00
|
|
|
format | description
|
|
|
|
--- | ---
|
2020-08-18 12:02:48 +03:00
|
|
|
amazon | Amazon EC2 image
|
2020-05-21 02:37:09 +03:00
|
|
|
azure | Microsoft azure image (Generation 1 / VHD)
|
2020-10-20 12:15:18 +03:00
|
|
|
cloudstack | qcow2 image for cloudstack
|
2019-12-01 20:25:19 +03:00
|
|
|
do | Digital Ocean image
|
2020-05-21 02:37:09 +03:00
|
|
|
gce | Google Compute image
|
|
|
|
hyperv | Hyper-V Image (Generation 2 / VHDX)
|
2019-01-19 00:17:38 +03:00
|
|
|
install-iso | Installer ISO
|
2019-12-01 22:10:37 +03:00
|
|
|
install-iso-hyperv | Installer ISO with enabled hyper-v support
|
2019-01-19 00:17:38 +03:00
|
|
|
iso | ISO
|
2019-01-20 23:32:05 +03:00
|
|
|
kexec | kexec tarball (extract to / and run /kexec_nixos)
|
|
|
|
kexec-bundle | same as before, but it's just an executable
|
2019-02-07 19:59:08 +03:00
|
|
|
lxc | create a tarball which is importable as an lxc container, use together with lxc-metadata
|
|
|
|
lxc-metadata | the necessary metadata for the lxc image to start, usage: lxc image import $(nixos-generate -f lxc-metadata) $(nixos-generate -f lxc)
|
2019-01-20 23:32:05 +03:00
|
|
|
openstack | qcow2 image for openstack
|
2020-05-10 16:33:05 +03:00
|
|
|
qcow | qcow2 image
|
2020-05-11 11:02:39 +03:00
|
|
|
raw | raw image with bios/mbr
|
2020-05-10 20:32:33 +03:00
|
|
|
raw-efi | raw image with efi support
|
2020-10-20 12:15:18 +03:00
|
|
|
sd-aarch64 | Like sd-aarch64-installer, but does not use default installer image config.
|
|
|
|
sd-aarch64-installer | create an installer sd card for aarch64. For cross compiling use `--system aarch64-linux` and read the cross-compile section.
|
2019-12-20 01:41:25 +03:00
|
|
|
vagrant-virtualbox | VirtualBox image for [Vagrant](https://www.vagrantup.com/)
|
2019-01-20 23:32:05 +03:00
|
|
|
virtualbox | virtualbox VM
|
2019-01-17 17:18:00 +03:00
|
|
|
vm | only used as a qemu-kvm runner
|
2020-07-30 13:56:09 +03:00
|
|
|
vm-bootloader | same as vm, but uses a real bootloader instead of netbooting
|
|
|
|
vm-nogui | same as vm, but without a GUI
|
2020-05-21 04:07:15 +03:00
|
|
|
vmware | VMWare image (VMDK)
|
2018-05-11 13:01:00 +03:00
|
|
|
|
2019-01-17 17:18:00 +03:00
|
|
|
## Usage
|
2018-05-11 13:01:00 +03:00
|
|
|
|
2019-08-19 17:07:08 +03:00
|
|
|
Run `nixos-generate --help` for detailed usage information.
|
2019-01-17 19:38:32 +03:00
|
|
|
|
2019-12-02 13:27:25 +03:00
|
|
|
## select a specific nixpkgs channel
|
|
|
|
|
|
|
|
adds ability to select a specific channel version.
|
|
|
|
|
|
|
|
example:
|
|
|
|
```
|
|
|
|
nix-shell --command './nixos-generate -f iso -I nixpkgs=channel:nixos-19.09'
|
|
|
|
```
|
|
|
|
|
2019-12-01 20:25:19 +03:00
|
|
|
## Using a particular nixpkgs
|
|
|
|
|
|
|
|
To use features found in a different nixpkgs (for instance the Digital Ocean
|
|
|
|
image was recently merged in nixpkgs):
|
|
|
|
|
|
|
|
```
|
|
|
|
NIX_PATH=nixpkgs=../nixpkgs nixos-generate -f do
|
|
|
|
```
|
|
|
|
|
2019-03-22 17:35:50 +03:00
|
|
|
## Cross Compiling
|
|
|
|
|
|
|
|
To cross compile nixos images for other system you have
|
|
|
|
to configure `boot.binfmtMiscRegistrations` on your host system.
|
|
|
|
|
|
|
|
For more details about this have a look at :
|
|
|
|
[clevers qemu-user](https://github.com/cleverca22/nixos-configs/blob/master/qemu.nix).
|
|
|
|
|
|
|
|
Once you've run `nixos-rebuild` with theses options,
|
|
|
|
you can use the `--system` option to create images for other architectures.
|
|
|
|
|
2019-01-17 19:38:32 +03:00
|
|
|
### License
|
2019-08-19 17:07:08 +03:00
|
|
|
|
2019-08-19 21:16:16 +03:00
|
|
|
This project is licensed under the [MIT License](LICENSE).
|