Stitch any CI into Tangled
1#!/bin/sh
2#
3# Buildkite pre-command hook: install Determinate Nix on the agent
4# before each command step runs. We rely on Nix (with flakes) for our
5# build environment, so every fresh agent needs it bootstrapped.
6#
7# Determinate's installer enables flakes and `nix-command` by default
8# and is more reliable in CI than the upstream installer, so we don't
9# need to stage a custom nix.conf.
10
11set -eu
12
13# Install Nix without touching the agent's init system. The `?ci=buildkite`
14# query param is informational; it lets Determinate tag installer telemetry.
15curl --proto '=https' --tlsv1.2 -sSf -L \
16 "https://install.determinate.systems/nix?ci=buildkite" \
17 | sh -s -- install linux --no-confirm --init none
18
19# Start the Determinate daemon ourselves since we passed `--init none`.
20# Point the Nix client at the daemon for the rest of this shell.
21nohup /usr/local/bin/determinate-nixd daemon &
22export NIX_REMOTE=daemon
23
24# Wait for the daemon to become responsive before handing control back
25# to the command step.
26while ! determinate-nixd status >/dev/null 2>&1; do
27 sleep 0.1
28done
29
30# Put `nix` on PATH for the command step. Buildkite sources hooks, so
31# this export propagates. With `--init none` we never edited any shell
32# profile, so we have to do it ourselves. The default profile holds the
33# `nix` binary; the per-user profile holds anything `nix profile install`
34# adds later.
35export PATH="/nix/var/nix/profiles/default/bin:$HOME/.nix-profile/bin:$PATH"