A NixOS flake for building a Lima-compatible system image.
This is a based on kasuboski/nixos-lima and there are about a half-dozen forks of that repo, but none of them (yet) seem to be making much of an effort to be generic/reusable, accept contributions, create documentation, etc. So I created this repo to try to create something that multiple developers can use and contribute to. (So now there are a half-dozen plus one projects 🤣 -- see xkcd "Standards")
There has been ongoing discussion in lima-vm/lima#430, and I have proposed there to create a "unified" project. If you have input or want to collaborate, please comment there or open an issue or pull request here. I'm also happy to archive this project and contribute to another one if other collaborators think that is a better path forward.
Currently, this flake supports building and booting a Lima NixOS image on both Linux and macOS and rebuilding NixOS from inside the VM. (I have not tested on x86, but it should work with minor tweaks.) Several of the existing forks contain features I would like to see integrated.
The following are the design goals that I think are important, but I'm definitely open to suggestions for changing these. (Just open an issue.)
- Nix flake that can build a bootable NixOS Lima-compatible image
- Be as generic and reusable by others as possible
- Nix modules for the systemd services that initialize and configure the system
- User customization of NixOS Lima instance is done separately from initial image creation
- Track the current nixos-unstable branch in Nix
A working Nix installation capable of building Linux systems. This includes:
- Linux system with Nix installed
- Linux VM with Nix installed (e.g. under macOS)
- macOS system with linux-builder installed via Nix Darwin
Flakes must be enabled.
nix build .#packages.aarch64-linux.img
If you built the image on another system:
mkdir result
# copy image to result/nixos.img
limactl start --name=nixos nixos.yaml
limactl shell nixos
# Using a VM shell, cd to this repository directory
nixos-rebuild switch --flake .#nixos --use-remote-sudo
See the NixOS Lima VM Config Sample.
Fork and clone that repository, check it out either to your macOS host or to a directory within you NixOS VM instance. Then use:
nixos-rebuild switch --flake .#sample --use-remote-sudo
Or change the name sample
to match the hostname of your NixOS Lima guest.
- NixOS Dev Environment on Mac January, 24 2023 by Josh Kasuboski
- Forked from: kasuboski/nixos-lima
- Heavily inspired by: patryk4815/ctftools
The unmodified, upstream README is in README_upstream.md
.
Fixes/patches from: