Files
flake-hub/ci/build.py
T
Oleks b319fe443b
ci/woodpecker/push/woodpecker Pipeline was successful
style: auto-format from pre-push hooks
2026-03-15 14:51:21 +02:00

54 lines
1.3 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 capture(cmd):
r = subprocess.run(cmd, shell=True, capture_output=True, text=True)
if r.returncode != 0:
print(r.stderr, file=sys.stderr)
sys.exit(r.returncode)
return r.stdout.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} ===")
# Setup attic
attic = (
capture(
"nix build --inputs-from . nixpkgs#attic-client --print-out-paths --no-link"
)
+ "/bin/attic"
)
run(f"'{attic}' login ci {ATTIC_SERVER} '{ATTIC_TOKEN}'")
# Packages per arch
packages = ["hello-world", "geesefs", "xonsh"]
if ARCH == "s390x-linux":
packages += ["attic-client"]
print("Building packages...")
for pkg in packages:
print(f"--- {pkg} ---")
out = capture(
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}")