Incus

From NixOS Wiki
Revision as of 08:05, 16 February 2024 by imported>Offlinehacker

Incus is a next generation system container and virtual machine manager. It is a community driven alternative to Canonical's LXD.

NixOS image

There is a pre-built NixOS image available at https://images.linuxcontainers.org/ providing both stable and unstable NixOS distributions.

To list available nixos images you can use incus image list command:

$ incus image list images:nixos
+-------------------------------+--------------+--------+---------------------------------------+--------------+-----------------+-----------+-------------------------------+
|             ALIAS             | FINGERPRINT  | PUBLIC |              DESCRIPTION              | ARCHITECTURE |      TYPE       |   SIZE    |          UPLOAD DATE          |
+-------------------------------+--------------+--------+---------------------------------------+--------------+-----------------+-----------+-------------------------------+
| nixos/23.11 (3 more)          | 4a84a70fb432 | yes    | Nixos 23.11 amd64 (20240216_01:02)    | x86_64       | CONTAINER       | 128.94MiB | Feb 16, 2024 at 12:00am (UTC) |
+-------------------------------+--------------+--------+---------------------------------------+--------------+-----------------+-----------+-------------------------------+
| nixos/23.11 (3 more)          | cee1d901cca2 | yes    | Nixos 23.11 amd64 (20240216_01:02)    | x86_64       | VIRTUAL-MACHINE | 467.54MiB | Feb 16, 2024 at 12:00am (UTC) |
+-------------------------------+--------------+--------+---------------------------------------+--------------+-----------------+-----------+-------------------------------+
| nixos/23.11/arm64 (1 more)    | 0881cc69ae39 | yes    | Nixos 23.11 arm64 (20240216_01:03)    | aarch64      | VIRTUAL-MACHINE | 474.89MiB | Feb 16, 2024 at 12:00am (UTC) |
+-------------------------------+--------------+--------+---------------------------------------+--------------+-----------------+-----------+-------------------------------+
| nixos/23.11/arm64 (1 more)    | c436a2e0a0e3 | yes    | Nixos 23.11 arm64 (20240216_01:03)    | aarch64      | CONTAINER       | 123.78MiB | Feb 16, 2024 at 12:00am (UTC) |
+-------------------------------+--------------+--------+---------------------------------------+--------------+-----------------+-----------+-------------------------------+
| nixos/unstable (3 more)       | 711ad413f1d4 | yes    | Nixos unstable amd64 (20240216_01:03) | x86_64       | VIRTUAL-MACHINE | 467.31MiB | Feb 16, 2024 at 12:00am (UTC) |
+-------------------------------+--------------+--------+---------------------------------------+--------------+-----------------+-----------+-------------------------------+
| nixos/unstable (3 more)       | b15681a4f2cf | yes    | Nixos unstable amd64 (20240216_01:03) | x86_64       | CONTAINER       | 174.39MiB | Feb 16, 2024 at 12:00am (UTC) |
+-------------------------------+--------------+--------+---------------------------------------+--------------+-----------------+-----------+-------------------------------+
| nixos/unstable/arm64 (1 more) | 95242674aa96 | yes    | Nixos unstable arm64 (20240216_01:03) | aarch64      | VIRTUAL-MACHINE | 475.38MiB | Feb 16, 2024 at 12:00am (UTC) |
+-------------------------------+--------------+--------+---------------------------------------+--------------+-----------------+-----------+-------------------------------+
| nixos/unstable/arm64 (1 more) | c0a02e8fd464 | yes    | Nixos unstable arm64 (20240216_01:03) | aarch64      | CONTAINER       | 168.44MiB | Feb 16, 2024 at 12:00am (UTC) |
+-------------------------------+--------------+--------+---------------------------------------+--------------+-----------------+-----------+-------------------------------+

To launch a new NixOS container use the following command:

incus launch images:nixos/unstable nixos -c security.nesting=true

security.nesting=true is needed for nix to work correctly.

Image is built using linuxcontainers CI job [1], the source of which can be found here [2]. As we can see jenkins CI job downloads lxdVirtualMachineImage derivation produced by hydra, which produces qcow2 image file. Configuration for nixos image can be found here [3].