Loading...
Loading...
Provision new NixOS servers on Proxmox for this nix flake project. Guides through the complete workflow: creating Proxmox LXC containers, SSH setup, Colmena configuration (init/full pattern), and application deployment with nginx proxy, PostgreSQL, and container images. Use when: (1) Creating a new server/container on Proxmox, (2) Setting up a new NixOS host with Colmena, (3) Deploying applications with nginx SSL proxy and/or PostgreSQL database, (4) Adding new container images to the repository.
npx skill4agent add fred-drake/nix provision-nixos-serverwoodpecker122thralllocal-lvmcephpool14096100host.<hostname>.admin_ip_addressPROXMOX_SERVER=<server>
HOSTNAME=<hostname>
CONTAINER_ID=<id>
STORAGE=local-lvm
MEMORY=4096
DISK_SIZE_IN_GB=100
ssh $PROXMOX_SERVER "pct create $CONTAINER_ID \
--arch amd64 local:vztmpl/nixos-system-x86_64-linux.tar.xz \
--ostype unmanaged \
--description nixos \
--hostname $HOSTNAME \
--net0 name=eth0,bridge=vmbr3,ip=dhcp,firewall=1 \
--storage $STORAGE \
--memory $MEMORY \
--rootfs $STORAGE:$DISK_SIZE_IN_GB \
--unprivileged 1 \
--features nesting=1 \
--cmode console \
--onboot 1 \
--start 1"cephpool1pct execssh $PROXMOX_SERVER "pct exec $CONTAINER_ID -- /run/current-system/sw/bin/bash -c '\
mkdir -p ~/.ssh && \
curl -s https://github.com/fred-drake.keys > ~/.ssh/authorized_keys && \
chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys'"ssh $PROXMOX_SERVER "pct exec $CONTAINER_ID -- /run/current-system/sw/bin/ip addr show eth0 | grep 'inet '"mkdir -p modules/nixos/host/<hostname>modules/nixos/host/<hostname>/configuration.nixcolmena/hosts/<hostname>.nixcolmena/default.nixrootdeployment = {
targetHost = "<DHCP_IP>";
targetUser = "root";
};git add colmena/hosts/<hostname>.nix modules/nixos/host/<hostname>/ colmena/default.nix
colmena build --impure --on <hostname>-initcolmena apply --impure --on <hostname>-initcolmena/hosts/<hostname>.nixdeployment = {
targetHost = soft-secrets.host.<hostname>.admin_ip_address;
targetUser = "default";
};colmena apply --impure --on <hostname>-initssh default@<NEW_IP> "mkdir -p ~/.ssh && chmod 700 ~/.ssh"
scp ~/.ssh/id_infrastructure default@<NEW_IP>:~/id_infrastructure
ssh default@<NEW_IP> "chmod 600 ~/id_infrastructure"age1rnarwmx5yqfhr3hxvnnw2rxg3xytjea7dhtg00h72t26dn6csdxqvsryg5.sops.yamlsops updatekeysapps/fetcher/containers.tomljust update-container-digestsgit add apps/fetcher/containers.toml apps/fetcher/containers-sha.nixapps/<appname>.nixmodules/secrets/<hostname>.nixpostgresql-env.sops<appname>-env.sopscolmena/hosts/<hostname>.nix../../modules/secrets/<hostname>.nix
../../apps/<appname>.nixjust update-secrets # Get latest secrets
git add <all-new-files>
colmena apply --impure --on <hostname>proxy_http_versionproxyWebsockets = true/var/lib/postgresql/var/lib/postgresql/data0.0.0.0:5432:5432host.containers.internal