This repository provides configuration and modules to build NixOS containers/images for Crostini (Linux on ChromeOS). The resulting guest supports:
- clipboard sharing,
- handling of URIs, URLs, etc,
- file sharing,
- X/Wayland forwarding, so that the guest can run GUI applications,
- port forwarding from guest to host.
See this blog post for more details about LXC support and this one for Baguette support.
- Install Nix.
- Run
nix flake init -t github:aldur/nixos-crostinifrom a new directory (or simply clone this repository). - Edit
./configuration.nixwith your username; later on, pick the same when configuring Linux on ChromeOS.
Now build a container image or a VM image.
Crostini runs LXC containers in a VM called termina. This repository
provides a Flake output and an NixOS module to build a custom LXC container
from your configuration.
# Build the container image and its metadata:
$ nix build .#lxc-image-and-metadata
$ ls result
image.tar.xz metadata.tar.xzThat's it! See this blog post for a few ways on how to deploy the image on the Chromebook.
You can also integrate the crostini.nix module in your Nix configuration. If
you are using flakes:
- Add this flake as an input.
- Add
inputs.nixos-crostini.nixosModules.crostinito your modules.
Here is a very minimal example:
{
# Here is the input.
inputs.nixos-crostini.url = "github:aldur/nixos-crostini";
# Optional:
inputs.nixos-crostini.inputs.nixpkgs.follows = "nixpkgs";
outputs = { self, nixpkgs, nixos-crostini }: {
# Change to your hostname.
nixosConfigurations.yourhostname = nixpkgs.lib.nixosSystem {
modules = [
./configuration.nix
# Here is where it gets added to the modules.
nixos-crostini.nixosModules.default
];
};
# Change <system> to "x86_64-linux", "aarch64-linux"
# This will allow you to build the image.
packages."<system>".lxc-image-and-metadata = nixos-crostini.packages."<system>".default;
};
}ChromeOS >= 141 provides experimental support for containerless Crostini (aka Baguette). This repository can build Baguette images that provide the same features of LXC containers (clipboard sharing, URIs handling, X/Wayland forwarding, etc) but allow more flexibility/freedom (e.g., to run Kubernetes without KVM).
# Build the image
$ nix build .#baguette-zimage
$ ls result
baguette_rootfs.img.zstTip
This CI pipeline builds Baguette images and uploads them as GitHub
workflow artifacts. If you fork this repository and commit a change to
./configuration.nix with your username, the CI will build a Baguette NixOS
image with your changes.
Copy baguette_rootfs.img.zst to the Chromebook "Downloads" directory. Open
crosh (Ctrl + Alt + t), configure the VM,
and launch the image:
vmc create --vm-type BAGUETTE \
--size 15G \
--source /home/chronos/user/MyFiles/Downloads/baguette_rootfs.img.zst \
baguette
vmc start --vm-type BAGUETTE baguette
[aldur@baguette-nixos:~]$Open new shell sessions with vsh baguette penguin.
This blog post shows further ways to configure, run, and customize a Baguette NixOS image.
This flake's nixosModules.baguette module allows building the image through
the output
nixosConfigurations.baguette-nixos.config.system.build.btrfsImageCompressed.
To adjust the size of the resulting disk image, set
virtualisation.diskImageSize (in MiB). You will need enough space to fit your
NixOS configuration.