7cd669804a
My specifications: - Nix code should receive a permissive license, in part not to copyleft away everyone's NixOS configurations for no good reason. - The companion tool should be protected by copyleft. - The templates should immediately rise to the public domain. - It should be very clear which part falls under which license. Based on that, I have selected the ISC and BSD-0 because they are short, and the GNU General Public License version 3 or later as a copyleft license. |
||
---|---|---|
checks | ||
lib | ||
miniguest | ||
modules | ||
template | ||
.envrc | ||
.gitignore | ||
COPYING.GPL3 | ||
COPYING.ISC | ||
default.nix | ||
devshell.toml | ||
flake.lock | ||
flake.nix | ||
README.md | ||
shell.nix |
Low-footprint NixOS images
This tool makes lightweight NixOS virtual machines and containers for popular virtualisation tools. The guest systems live entirely on the host's Nix store. The host system does not need to be NixOS.
How lightweight?
Lighter than if it were the host system. There is no disk image, no bootloader, no ISO. Just plain immutable file that are friendly to Nix's deduplication mechanisms.
Support Vector
Libvirt KVM guests are the current primary focus. Any hypervisor that is capable of direct-kernel boot can most likely work as well. Libvirt OS containers will come in the future.
Installation
If the Nix you drive already has flakes enabled, just use the following command:
nix profile install github:bbjubjub2494/miniguest
Otherwise don't worry, miniguest can be bootstrapped under Nix 2.3 and older with with:
nix-env -if https://github.com/bbjubjub2494/miniguest/archive/refs/heads/master.zip
If you do not have Nix installed, refer to this page, then look at the second command.
Getting started
You base your flake on the template. Copy the template/
directory from the
repository, or run:
nix flake new -t github:bbjubjub2494/miniguest
Usage
Guest system configuration must be presented within a Nix flake, import the
nixosModules.miniguest
module from the miniguest flake, and set
boot.miniguest.enable
to true. The miniguest tool can then be invoked with
sudo miniguest install «flakePath»#«guestName»
The configuration will then be built and will appear under
/etc/miniguests/«guestName»
.
It is recommended to create at most one domain per configuration so that they can all be rebuilt independently of each other.
Related work
-
nixos-container
: Miniguest takes inspiration from NixOS's containers, however, containers wrapssystemd-nspawn
, whereas miniguests delegates actual guest management to any supported hypervisor. -
nixos-rebuild build-vm
: Miniguest borrows the store-sharing mechanism from NixOS's built-in lightweight QEMU VMs when applicable, but it lets libvirt take care of the VM configuration and lifecycle.