This repository contains a modular setup for managing NixOS configurations across multiple virtual machines (VMs). Common configurations are stored in base.nix, and VM-specific configurations are stored in the vm-configs/ directory. Each VM's configuration.nix will import the appropriate configuration while leaving machine-specific files (like hardware-configuration.nix) untouched.
YMMV with this setup. It was only used in a prototyped manner. Adopt and fork for your own use if desired!
- Modular Configuration: Common configurations are stored in
base.nix, while each VM has its specific configuration in thevm-configs/directory (e.g.,metabase-app.nix). - VM-Specific Configuration: Each machine should maintain its own
hardware-configuration.nix, generated by NixOS, and its ownconfiguration.nix, which imports the VM-specific configuration from thevm-configs/directory. - Git Tracking: The repository does not track
configuration.nixandhardware-configuration.nix, allowing each machine to maintain these files independently.
When setting up a ProxMox VM for NixOS, follow these steps:
- Boot Mode: Default (SeaBIOS)
- Network Bridge: Vmbr01 - For public IP addresses
- Storage: Select
local - ISO File:
NixOS-minimal-24.05.iso
If you would like to paste commands into the noVNC console, you can use this Tampermonkey UserScript (caution advised!)
Once the system is booted, you are automatically logged in as the nixos user. The nixos user account has an empty password, so you can use sudo without a password.
Use the following commands to run the installation script. You will be prompted for your Git credentials.
sudo -i
curl -s https://gist.githubusercontent.com/explorier/c831de732ea8c582a98630950aa25bcb/raw/setup_nixos.sh -o setup_nixos.sh
bash setup_nixos.sh https://github.com/explorier/NixosConfig.gitUpon successful installation, the system will reboot.
After reboot, login as root.
Then you can create a file to configure the current VM inside of the /etc/nixos/vm-configs directory and import it into the configuration.nix file.
To apply the base config, or test and build your config , run the nixos-rebuild switch command 🎉
If you'd like to set a password for the admin account to enable sudo su when connecting via SSH, run sudo passwd admin
Feel free to open an issue or submit a pull request if you have suggestions for improving this setup.
By following this strategy, we can maintain both shared and VM-specific configurations across multiple machines while keeping machine-specific files like hardware-configuration.nix untouched.