NixOS-generators – Collection of VM and Container disk image builders for NixOS
github.com
github.com
I recently used this NixOS module to build a new machine as a Proxmox VMA all while sharing the common config with my existing NixOS machine. I then imported the VM into Proxmox, expanded the disk size, and it booted immediately! There were a few manual things I had to do to get secrets working, but end-to-end, it took me about 5 minutes.
You can do the exact same thing for other formats. For example, you could have a bootable installer ISO that takes your base config and adds specific tools on top that you’d want on a portable USB.
Building NixOS qcow2 images with flakes:
https://tarnbarford.net/journal/building-nixos-qcow2-images-...
Build a bare bones bootable nixos qcow2 image suitable for running with libvirt/qemu/kvm:
https://gist.github.com/tarnacious/f9674436fff0efeb4bb6585c7...
A Journey into Nix and NixOS (Building a QEMU image):
https://williamvds.me/blog/journey-into-nix/#:~:text=Buildin...
Setting up qemu VM using nix flakes:
https://gist.github.com/FlakM/0535b8aa7efec56906c5ab5e32580a...
There is a good blog post here about how these work: https://www.tweag.io/blog/2020-07-31-nixos-flakes/
And of course, it is just a tarball, so it works on every systemd based distro.
"Not-OS – NixOS-based OS generator that outputs an OS with 47MB squashfs":
https://news.ycombinator.com/item?id=34679031
https://github.com/cleverca22/not-os
For memory constrained VMs and containers based on NixOS...
Of course, even that isn't as small as Alpine's absolutely tiny 5MB Docker image:
What's the most pleasant way to develop and build nix images if your dev env is a regular Linux distro without nix installed?
So far the least bad seems to be running Nixos in a VM with VS Code remote via SSH and scp'ing images around. At least quickemu makes getting the VM pleasant. But VMs are cumbersome.
Docker would be great, but nix from the official Docker container doesn't seem to like running as non-root, which means you can't use volume mounts for the code and change the user ID so that the file permissions are right from inside the container.
And this as a second reference: https://nix.dev/tutorials/first-steps/index.html
Some specific ones I really like:
https://github.com/malob/nixpkgs
https://github.com/fufexan/dotfiles
I keep a not comprehensive GitHub Stars list of Nix stuff I find here if you want more:
https://github.com/stars/heywoodlh/lists/nix
If you aren’t familiar, Nix-Darwin allows you to codify your MacOS deployments in a fashion comparable to NixOS. As a huge Nix-Darwin user myself, I have found malob’s repo extremely helpful for ideas with MacOS configuration. Nix-Darwin has made me so happy as a MacOS user. :)
Some other unsolicited tips:
1. Start with Nix flakes for configuration
2. Invest in Home-Manager before NixOS or Nix-Darwin
3. Ask people for help in Matrix or Discourse — my experience is that Nix-related folk are very welcoming and understanding
Good luck!