nixos-lima-config-sample

June 24, 2026 ยท View on GitHub

A sample NixOS configuration flake that uses the nixos-lima module to enable running NixOS within a Lima-managed VM on macOS and Linux.

This repository can be used as a template for your custom NixOS Lima VM configuration. Because it references the nixos-lima module, you should be able to update to new and improved versions while maintaining the configuration of your VM separately/privately.

The sample BASH scripts setup-nixos.sh and setup-home-manager.sh are used to check out Git repositories for Home Manager and NixOS system configuration, respectively and to build/switch to that configuration. These mechanisms allow you to configure and manage a NixOS Lima VM and track changes in a Git repository.

This example uses the latest base image release from nixos-lima.

Prerequisites

  • macOS 13.5+ or recent Linux with Lima installed

NOTE: Nix is not needed to run a NixOS Lima VM (e.g. you can install Lima with Homebrew or another mechanism and start a guest VM running NixOS)

Installation

Check out this repository to your Lima host. The following commands can be used with no customization of this repository. (The main username for the guest VM, "lima" is hardcoded in homeConfigurations."lima" in flake.nix.)

limactl start --yes --set '.user.name = "lima"' nixos.yaml
./setup-nixos.sh nixos nixsample-aarch64
./setup-home-manager.sh nixos lima

If you create a fork or copy of this repo, or use your own Home Manager flake, you can use the same username as you use on the host system, making the commands simpler:

limactl start --yes nixos.yaml
./setup-nixos.sh nixos nixsample-aarch64
./setup-home-manager.sh nixos $USER

You can then log in to your NixOS guest VM using:

limactl shell nixos

NOTE: By default, both setup-nixos.sh and setup-home-manager.sh use git clone to fetch their Nix flake configurations directly from the master branch of this repository. Local changes to a checkout of the *.nix files will not be seen until you push them to your own remote Git repo and either change DEFAULT_CONFIG_REPO in the scripts or use the scripts config-repo parameter to override DEFAULT_CONFIG_REPO.

Help Wanted

Feedback, issues, and pull-requests are all most welcome.