push green meta builds to the attic cache and record cached
This commit is contained in:
parent
c4e8d5b540
commit
0849afec80
1 changed files with 779 additions and 31 deletions
|
|
@ -17,8 +17,8 @@
|
|||
#
|
||||
# The container holds one credential, its own store leaf, which nspawn hands in
|
||||
# as a system credential with no copy on disk. The daemon reads everything else
|
||||
# from the store with it: its queue client secret at start and its forge token
|
||||
# on every build.
|
||||
# from the store with it: its queue client secret at start, its forge token
|
||||
# on every build and, where a cache is set, its cache push token on every push.
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
|
|
@ -33,6 +33,7 @@ let
|
|||
natsCfg = hyperhiveCfg.swarm.nats;
|
||||
autheliaCfg = hyperhiveCfg.swarm.authelia;
|
||||
forgeCfg = hyperhiveCfg.swarm.forge;
|
||||
atticCfg = hyperhiveCfg.swarm.attic;
|
||||
gatewayCfg = hyperhiveCfg.gateway;
|
||||
networkCfg = hyperhiveCfg.network;
|
||||
tlsCfg = hyperhiveCfg.deploy.hive-controller.tls;
|
||||
|
|
@ -89,6 +90,9 @@ let
|
|||
hyperhiveFlake = hyperhiveCfg.c0re.hyperhiveFlake;
|
||||
nixpkgsFlake = hyperhiveCfg.c0re.nixpkgsFlake;
|
||||
|
||||
# Either half alone reaches the daemon too, which refuses to start on it.
|
||||
pushesToCache = atticCfg.domain != null || atticCfg.cache != null;
|
||||
|
||||
privateNetwork = true;
|
||||
in
|
||||
{
|
||||
|
|
@ -230,8 +234,9 @@ in
|
|||
wantedBy = [ "multi-user.target" ];
|
||||
wants = [ "network-online.target" ];
|
||||
after = [ "network-online.target" ];
|
||||
# nix fetches the config repo with `git`.
|
||||
path = [ pkgs.git ];
|
||||
# nix fetches the config repo with `git`, and a green build is pushed
|
||||
# with `attic` where a cache is set.
|
||||
path = [ pkgs.git ] ++ lib.optional pushesToCache pkgs.attic-client;
|
||||
environment = {
|
||||
BAO_ADDR = "https://${baoCfg.domain}:${toString baoCfg.port}";
|
||||
BAO_CLIENT_CERT = credential "builder-bao-cert";
|
||||
|
|
@ -252,6 +257,12 @@ in
|
|||
SWARM_BUILDER_FORGE_URL = "https://${forgeCfg.domain}";
|
||||
SWARM_BUILDER_CONFIG_ORG = "agent-configs";
|
||||
}
|
||||
// lib.optionalAttrs (atticCfg.domain != null) {
|
||||
SWARM_BUILDER_ATTIC_DOMAIN = atticCfg.domain;
|
||||
}
|
||||
// lib.optionalAttrs (atticCfg.cache != null) {
|
||||
SWARM_BUILDER_ATTIC_CACHE = atticCfg.cache;
|
||||
}
|
||||
// lib.optionalAttrs (storeFiles ? builder-bao-server-ca) {
|
||||
BAO_CACERT = credential "builder-bao-server-ca";
|
||||
}
|
||||
|
|
@ -264,6 +275,10 @@ in
|
|||
ExecStart = "${cfg.package}/bin/swarm-builder";
|
||||
DynamicUser = true;
|
||||
CacheDirectory = unit;
|
||||
# /run/swarm-builder, mode 0700 and owned by the dynamic user: the
|
||||
# push writes its token-bearing `attic` config under it.
|
||||
RuntimeDirectory = unit;
|
||||
RuntimeDirectoryMode = "0700";
|
||||
# Bare ids: the system credentials nspawn handed in.
|
||||
LoadCredential = lib.attrNames storeFiles;
|
||||
Restart = "on-failure";
|
||||
|
|
|
|||
Loading…
Reference in a new issue