This repository provides a sample Nix configuration to build NixOS containers
for Crostini (Linux on ChromeOS). The crostini.nix module adds support for:
- clipboard sharing with the container,
- handling of URIs, URLs, etc,
- file sharing,
- and X/Wayland support, so that the container can run GUI applications.
See this blog post for more details.
- Install Nix.
- Run
nix flake init -t github:aldur/nixos-crostinifrom a new directory (or simply clone this repository). - Edit the
./configuration.nixwith your username; later on, pick the same when configuring Linux on ChromeOS.
Then:
# Build the container image and its metadata:
$ nix build
$ ls result
image.tar.xz metadata.tar.xzThat's it! See this other 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.nixos-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;
};
}This fork includes several specific modifications and improvements:
- User Configuration: The default user is pre-configured as
ertugruleratainconfiguration.nix. - CI/CD Pipeline: A GitHub Actions workflow (
.github/workflows/ci.yml) is included to automatically build the LXC image and metadata.- Artifacts: Every build produces
image.tar.xzandmetadata.tar.xz, which can be downloaded from the "Actions" tab in GitHub.
- Artifacts: Every build produces
- Flake Fixes: The
crostini.nixmodule is explicitly included in the flake outputs to ensure critical files (like/etc/gshadowviacommon.nix) are generated correctly during the LXC build. - Baguette Exclusion: Specific "Baguette" related features have been excluded to keep the image minimal and focused on standard Crostini usage.
You do not need to build locally if you use the CI artifacts:
- Go to the Actions tab of this repository.
- Click on the latest successful workflow run.
- Scroll down to Artifacts and download
nixos-crostini-x86_64-linux. - Extract the zip file to get
image.tar.xzandmetadata.tar.xz.