snix/ops/pipelines/depot.nix
Florian Klink 8c4f447ec7 fix(ops/pipelines): fix anchor steps
Every buildkite user needs to be able to update these symlinks, and the
directory doesn't exist. It was probably created imperatively on whitby.

Use a tmpfiles rule creating a /nix/var/nix/gcroots/buildkite directory,
and add a `canon` symlink in there.

Change-Id: Ic4d67fbb69f77cebe891b0fff9b824713ebec87c
Reviewed-on: https://cl.snix.dev/c/snix/+/30247
Tested-by: besadii
Autosubmit: Florian Klink <flokli@flokli.de>
Reviewed-by: Ilan Joselevich <personal@ilanjoselevich.com>
2025-03-23 00:48:45 +00:00

46 lines
1.5 KiB
Nix

# This file configures the primary build pipeline used for the
# top-level list of depot targets.
{ depot, pkgs, externalArgs, ... }:
let
pipeline = depot.nix.buildkite.mkPipeline {
headBranch = "refs/heads/canon";
drvTargets = depot.ci.targets;
parentTargetMap =
if (externalArgs ? parentTargetMap)
then builtins.fromJSON (builtins.readFile externalArgs.parentTargetMap)
else { };
postBuildSteps = [
# After successful builds, create a gcroot for builds on canon.
#
# This anchors *most* of the depot, in practice it's unimportant
# if there is a build race and we get +-1 of the targets.
#
# Unfortunately this requires a third evaluation of the graph, but
# since it happens after :duck: it should not affect the timing of
# status reporting back to Gerrit.
{
label = ":anchor:";
branches = "refs/heads/canon";
command = ''
rm /nix/var/nix/gcroots/buildkite/canon
nix-build -A ci.gcroot --out-link /nix/var/nix/gcroots/buildkite/canon
'';
# Ensure that anchoring happens on build01, so that a possibly deployed
# binary cache there has the store paths. Unanchored machines may
# garbage collect live paths.
agents.hostname = "build01";
}
];
};
drvmap = depot.nix.buildkite.mkDrvmap depot.ci.targets;
in
pkgs.runCommand "depot-pipeline" { } ''
mkdir $out
cp -r ${pipeline}/* $out
cp ${drvmap} $out/drvmap.json
''