nix on ubuntu?
All checks were successful
Hello World / test (push) Successful in 2s

This commit is contained in:
plasmagoat 2025-06-07 02:22:42 +02:00
parent f49c705d36
commit 760cb102d4
2 changed files with 30 additions and 20 deletions

View file

@ -1,42 +1,53 @@
name: Build and Upload NixOS Image
name: "Build NixOS Image"
on:
workflow_dispatch:
jobs:
build:
runs-on: [nixos]
runs-on: ubuntu-latest
defaults:
run:
working-directory: nixos
steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixos-unstable
extra_nix_config: |
experimental-features = nix-command flakes
- name: Build NixOS image
run: nix build .#nixosImage
- name: Upload image to Proxmox
- name: Upload & Restore to Proxmox
env:
SSH_KEY: ${{ secrets.PROXMOX_SSH_KEY }}
PROXMOX_USER: root
PROXMOX_SSH_KEY: ${{ secrets.PROXMOX_SSH_KEY }}
PROXMOX_HOST: 192.168.1.205
PROXMOX_USER: root
run: |
mkdir -p ~/.ssh
echo "$SSH_KEY" > ~/.ssh/id_proxmox
chmod 600 ~/.ssh/id_proxmox
export SSH="ssh -i ~/.ssh/id_proxmox -o StrictHostKeyChecking=no"
export SCP="scp -i ~/.ssh/id_proxmox -o StrictHostKeyChecking=no"
set -e
IMAGE=$(find result/ -name '*.vma.zst' | head -n 1)
NAME=$(basename "$IMAGE")
IMAGE_NAME="vm-image.vma.zst"
REMOTE_PATH="/var/lib/vz/template/$IMAGE_NAME"
VM_ID="9000"
echo "Uploading $IMAGE to $PROXMOX_HOST..."
$SCP "$IMAGE" "$PROXMOX_USER@$PROXMOX_HOST:/var/lib/vz/dump/"
echo "Starting ssh-agent and uploading..."
eval "$(ssh-agent -s)"
ssh-add <(echo "$PROXMOX_SSH_KEY")
echo "Restoring and converting to template..."
$SSH "$PROXMOX_USER@$PROXMOX_HOST" "
qmrestore /var/lib/vz/dump/$NAME 9000 --unique --replace &&
qm template 9000
echo "Uploading image..."
scp -o StrictHostKeyChecking=no ./result/$IMAGE_NAME $PROXMOX_USER@$PROXMOX_HOST:$REMOTE_PATH
echo "Restoring VM $VM_ID..."
ssh -o StrictHostKeyChecking=no $PROXMOX_USER@$PROXMOX_HOST "
qm stop $VM_ID || true
qm destroy $VM_ID || true
qmrestore --unique $REMOTE_PATH $VM_ID
qm template $VM_ID
"

View file

@ -20,7 +20,6 @@
# "ubuntu-22.04:docker://node:16-bullseye"
# "ubuntu-20.04:docker://node:16-bullseye"
# "ubuntu-18.04:docker://node:16-buster"
"nixos:docker://cachix/nix-build-action"
## optionally provide native execution on the host:
# "native:host"
];