1.9 KiB
1.9 KiB
NixOS x Proxmox infra configuration with Terranix
This repository allows to manage LXC containers on Proxmox.
It's supposed to be used from an host where nixos-rebuild is available.
- Uses
nix-community/generatorsto build a LXC template with a base NixOS container - Uses
terranixto build the infra definition andopentofuto deploy it on Proxmox - Uses
nixos-rebuildto deploy the configuration on the container
My main objective was to have a "light" definition for the containers and to be able to use Nix to factorize configuration.
Usage
Prepare the infra constants
cp lib/constants.nix.template lib/constants.nix- adapt
lib/constants.nixto match your needs - touch
lib/ips.nix - remove both these files from
.gitignoreandgit addthem.
Build NixOS template
- modify
lib/lxc-template.nixas needed - run
build-template - template available in
nixos-template/tarball/(.tar.xz to be uploaded to Proxmox)
TODO Script the Proxmox Template upload if possible.
Prepare Terraform
- create a user/role etc on Proxmox (see the provider documentation)
cp terraform.tfvars.example terraform.tfvars- edit
terraform.tfvarsto fill in values - adapt the terraform base config as needed in
infra/main.nix - run
tofu init
Adapt NixOS / Terraform modules building
- edit
lib/container_build.nixto change how a container definition is translated to TF / NixOS config (in particular check the template name)
Create containers definitions
- run
add-lxc [name] [id] - edit
lxc/#NAME#.nixas needed - run
build-terraform-json - run
tofu planand review the plan - run
tofu apply, hopefully without errors - run
deploy-lxc #NAME#
Update container
- edit
lxc/#NAME#.nixas needed - if the container specs have changed, do all as above
- otherwise you can just run
deploy-lxc #NAME#