NixOS and Home-Manager configuration.
Assumes use of Nix flakes.
The steps refer to this new hosts as "example", rename as you see fit.
cd <parent-dir>/nix-config
mkdir hosts/example
nix-shell -p nixos-install-tools
nixos-generate-config --dir hosts/example
- Build:
nixos-rebuild build --flake .#<hostname>
- Switch (usually requires
sudo
):
nixos-rebuild switch --flake .#<hostname>
Use this for non-NixOS machines
- Build:
home-manager build --flake .#<username>@<hostname>
- Switch:
home-manager switch --flake .#<username>@<hostname>
nix flake update
These insructions are based on the NixOS which page Proxmox Virtual Environment
-
Create a new configuration for the machine
-
Ensure to change the user password hash
-
Generate the machine image using
nixos-generators
by runningnix run github:nix-community/nixos-generators -- --format proxmox --configuration hosts/media/configuration.nix
-
Upload the image to the Proxmox host
-
Restore the image as a running VM
qmrestore /var/lib/vz/dump/vzdump-qemu-nixos-21.11.git.d41882c7b98M.vma.zst <vmid> --unique true
root@proxmox-server:~# qm start <vmid> root@proxmox-server:~# qm terminal <vmid>
nix run --extra-experimental-features nix-command --extra-experimental-features flakes --no-write-lock-file github:nix-community/home-manager/ -- --flake ".#$USER@$HOSTNAME" --extra-experimental-features nix-command --extra-experimental-features flakes switch -b backup