This is one of the “magical” capabilities provided by Nix and NixOS imo.
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.
I've recently been experimenting with nix generators. It's nice.
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.
This caught my attention, and now I want to dive into NixOS more. Can anyone suggest a solid set of starting resources for someone with a (probably overly complex) home lab and experience with macOS and Ubuntu/Debian?
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
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.