#!/usr/bin/env bash set -e TEMPLATE=/tmp/nixos.tar.xz [ -e $TEMPLATE ] || wget -O $TEMPLATE https://hydra.nixos.org/job/nixos/release-21.05/nixos.containerTarball.x86_64-linux/latest/download-by-type/file/system-tarball if [ $# != 2 ]; then echo "Usage: $0 " exit 1 fi ID=$1 NAME=$2 # todo vater@c3d2.de # schaffen der moeglichkeit zum hinzufuegen von einem oeffentlichen schluessel fuer ssh (fuer das konto root) # (es gab beim "durchexerzieren" 2021-09-04 eine situation wo es noetig gewesen waere einen key hinterlegt zu haben.) # https://pve.proxmox.com/pve-docs/pct.1.html # --ssh-public-keys # storage: there's enough of slow # memory: enough for building stuff # net vlan tag 5: c3d2 (with dhcp). request a static IP address with Astro and move to 3 (serv). pct create $ID $TEMPLATE --hostname $NAME --ostype unmanaged --arch amd64 --net0 name=eth0,bridge=vmbr0,tag=5 --storage vms-slow --memory 4096 --cmode shell --features nesting=1 # this boots the current profile echo "lxc.init.cmd: /init" >> /etc/pve/lxc/$ID.conf echo Starting $ID pct start $ID run() { lxc-attach -n $ID -- /run/current-system/sw/bin/sh -c ". /etc/profile && $*" } echo -n Wait for container to ship while S=$(run systemctl is-system-running --wait 2> /dev/null); [ "$S" != running ] && [ "$S" != degraded ]; do sleep 1 echo -n . done echo " $S" echo Preparing sensible defaults run "cat > /etc/nixos/configuration.nix" < /dev/null; do sleep 1 echo -n . done echo " fast" # Fixup init path to use new profile sed -e "s#lxc.init.cmd: /init#lxc.init.cmd: /sbin/init#" -i /etc/pve/lxc/$ID.conf # Rebuild run nixos-rebuild switch