Files
flake-hub/ci/build.py
T
Oleks 80c05b582e
ci/woodpecker/push/woodpecker Pipeline was successful
ci: make env probes non-fatal, swap free for /proc/meminfo
Pipeline #41 died with exit 127 on `free -h` — procps isn't in the
nix-ci image. New info() helper runs the command and ignores the exit
code, so missing tools no longer abort the build. Also switched to
/proc/meminfo since it's always available on Linux.
2026-04-29 11:44:50 +03:00

74 lines
2.1 KiB
Python

#!/usr/bin/env python3
"""Build all flake-hub packages and push to attic."""
import os
import subprocess
import sys
def run(cmd):
print(f"+ {cmd}", flush=True)
r = subprocess.run(cmd, shell=True)
if r.returncode != 0:
sys.exit(r.returncode)
def info(cmd):
"""Like run(), but tolerant of failure — for non-load-bearing diagnostics."""
print(f"+ {cmd}", flush=True)
subprocess.run(cmd, shell=True)
def build(cmd):
"""Run a `nix build`, streaming stderr live; return stdout (the out path)."""
print(f"+ {cmd}", flush=True)
proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, text=True)
out, _ = proc.communicate()
if proc.returncode != 0:
sys.exit(proc.returncode)
return out.strip()
ARCH = sys.argv[1]
ATTIC_CACHE = "attic-infra-cache-k3s-1"
ATTIC_SERVER = "https://nix-cache-upload.oleks.space"
ATTIC_TOKEN = os.environ["ATTIC_TOKEN"]
print(f"=== Building flake-hub packages for {ARCH} ===")
# Environment context for log readers
info("nix --version")
info("uname -a")
info("df -h /nix 2>/dev/null || df -h /")
info("cat /proc/meminfo | head -3")
# Setup attic
attic = (
build(
"nix build --inputs-from . nixpkgs#attic-client --print-build-logs --print-out-paths --no-link"
)
+ "/bin/attic"
)
run(f"'{attic}' login ci {ATTIC_SERVER} '{ATTIC_TOKEN}'")
# Packages per arch
packages = ["hello-world", "geesefs", "xonsh"]
# google-antigravity{,-no-fhs} skipped in CI: pulls in google-chrome, which
# transitively builds liberation-fonts; fontforge segfaults while generating
# the .ttf files (pipeline #40). Package definitions stay in the flake for
# local builds — re-enable here once upstream fontforge is fixed.
# if ARCH == "x86_64-linux":
# packages += ["google-antigravity", "google-antigravity-no-fhs"]
if ARCH == "s390x-linux":
packages += ["attic-client"]
print("Building packages...")
for pkg in packages:
print(f"--- {pkg} ---")
out = build(
f"nix build '.#packages.{ARCH}.{pkg}' --print-build-logs --print-out-paths --no-link"
)
run(f"'{attic}' push {ATTIC_CACHE} {out}")
print(f"Build completed for {ARCH}")