From 71421f812cb8dcc361314eff94e1bb7d102029a0 Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Fri, 24 Mar 2023 12:14:33 +0100 Subject: [PATCH] wait for the nix daemon --- README.md | 14 +++++++++++++- hcl/builder.hcl | 6 ++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5c55d24..62d0164 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,19 @@ docker run --rm -it dxflrs/albatros:xxx where `xxx` is the commit sha you want. -## Builders +## Bring Your Own Builder + +One aspect that I don't like with traditional CI is that the way you can +configure builds is very constrained by the vendor implementation choices. +Like it or not, but Albatros has very few constraints in term of what build infrastructure should look like: + - It must be a Nomad parameterized job + - Your job must accept four mandatory meta parameters: `REPO_URL`, `COMMIT`, `BRANCH`, `FLAVOR` + - Your job may receive a payload containing the secrets stored in your job definition (subject to change) + - It must have have a task group named `runner` and, inside this group, a task named `executor` + +And... that's basically all you need. + +### A NixOS builder with local cache Currently, we propose a single, nix-based builder. I am currently working on using proper caching on it. diff --git a/hcl/builder.hcl b/hcl/builder.hcl index 6f1c8e5..6094eee 100644 --- a/hcl/builder.hcl +++ b/hcl/builder.hcl @@ -86,6 +86,7 @@ fi #!/usr/bin/env bash set -euxo pipefail +# setup workspace mkdir /workspace cd /workspace git init @@ -95,6 +96,11 @@ git checkout ${NOMAD_META_COMMIT} -b ${NOMAD_META_BRANCH} if [[ -s /var/run/secrets/albatros/secret.txt ]]; then export SECRET_PATH=/var/run/secrets/albatros/secret.txt fi + +# wait for nix daemon during 120 seconds +timeout -s 9 120 bash -c 'until nix store ping; do sleep 2; done' + +# launch user's build ./.albatros EOH