mirror of
https://github.com/NixOS/hydra.git
synced 2024-10-22 22:59:17 +02:00
Merge remote-tracking branch 'upstream/master' into use-store-api
This commit is contained in:
commit
181b52787e
|
@ -74,6 +74,30 @@ following:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Populating a Cache
|
||||||
|
------------------
|
||||||
|
|
||||||
|
A common use for Hydra is to pre-build and cache derivations which
|
||||||
|
take a long time to build. While it is possible to direcly access the
|
||||||
|
Hydra server's store over SSH, a more scalable option is to upload
|
||||||
|
built derivations to a remote store like an [S3-compatible object
|
||||||
|
store](https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-help-stores.html#s3-binary-cache-store). Setting
|
||||||
|
the `store_uri` parameter will cause Hydra to sign and upload
|
||||||
|
derivations as they are built:
|
||||||
|
|
||||||
|
```
|
||||||
|
store_uri = s3://cache-bucket-name?compression=zstd¶llel-compression=true&write-nar-listing=1&ls-compression=br&log-compression=br&secret-key=/path/to/cache/private/key
|
||||||
|
```
|
||||||
|
|
||||||
|
This example uses [Zstandard](https://github.com/facebook/zstd)
|
||||||
|
compression on derivations to reduce CPU usage on the server, but
|
||||||
|
[Brotli](https://brotli.org/) compression for derivation listings and
|
||||||
|
build logs because it has better browser support.
|
||||||
|
|
||||||
|
See [`nix help
|
||||||
|
stores`](https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-help-stores.html)
|
||||||
|
for a description of the store URI format.
|
||||||
|
|
||||||
Statsd Configuration
|
Statsd Configuration
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
|
|
|
@ -42,16 +42,16 @@
|
||||||
"nixpkgs-regression": "nixpkgs-regression"
|
"nixpkgs-regression": "nixpkgs-regression"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1701122567,
|
"lastModified": 1702510710,
|
||||||
"narHash": "sha256-iA8DqS+W2fWTfR+nNJSvMHqQ+4NpYMRT3b+2zS6JTvE=",
|
"narHash": "sha256-9K+w1mQgmUxCmEsPaSFkpYsj/cxjO2PSwTCPkNZ/NiU=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nix",
|
"repo": "nix",
|
||||||
"rev": "50f8f1c8bc019a4c0fd098b9ac674b94cfc6af0d",
|
"rev": "b38e5a665e9d0aa7975beb0ed12e42d13a392e74",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"ref": "2.19.2",
|
"ref": "2.19-maintenance",
|
||||||
"repo": "nix",
|
"repo": "nix",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
description = "A Nix-based continuous build system";
|
description = "A Nix-based continuous build system";
|
||||||
|
|
||||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
|
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
|
||||||
inputs.nix.url = "github:NixOS/nix/2.19.2";
|
inputs.nix.url = "github:NixOS/nix/2.19-maintenance";
|
||||||
inputs.nix.inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nix.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
|
||||||
outputs = { self, nixpkgs, nix }:
|
outputs = { self, nixpkgs, nix }:
|
||||||
|
|
|
@ -143,7 +143,7 @@ void State::buildRemote(ref<Store> destStore,
|
||||||
{
|
{
|
||||||
auto activeStepState(activeStep->state_.lock());
|
auto activeStepState(activeStep->state_.lock());
|
||||||
if (activeStepState->cancelled) throw Error("step cancelled");
|
if (activeStepState->cancelled) throw Error("step cancelled");
|
||||||
activeStepState->pid = child.pid;
|
activeStepState->pid = child.sshPid;
|
||||||
}
|
}
|
||||||
|
|
||||||
Finally clearPid([&]() {
|
Finally clearPid([&]() {
|
||||||
|
|
|
@ -495,12 +495,14 @@ Step::ptr State::createStep(ref<Store> destStore,
|
||||||
|
|
||||||
size_t avail = 0;
|
size_t avail = 0;
|
||||||
for (auto & i : missing) {
|
for (auto & i : missing) {
|
||||||
auto path = i.second.path(*localStore, step->drv->name, i.first);
|
auto pathOpt = i.second.path(*localStore, step->drv->name, i.first);
|
||||||
if (/* localStore != destStore && */ localStore->isValidPath(*path))
|
assert(pathOpt); // CA derivations not yet supported
|
||||||
|
auto & path = *pathOpt;
|
||||||
|
if (/* localStore != destStore && */ localStore->isValidPath(path))
|
||||||
avail++;
|
avail++;
|
||||||
else if (useSubstitutes) {
|
else if (useSubstitutes) {
|
||||||
SubstitutablePathInfos infos;
|
SubstitutablePathInfos infos;
|
||||||
localStore->querySubstitutablePathInfos({{*path, {}}}, infos);
|
localStore->querySubstitutablePathInfos({{path, {}}}, infos);
|
||||||
if (infos.size() == 1)
|
if (infos.size() == 1)
|
||||||
avail++;
|
avail++;
|
||||||
}
|
}
|
||||||
|
@ -509,25 +511,27 @@ Step::ptr State::createStep(ref<Store> destStore,
|
||||||
if (missing.size() == avail) {
|
if (missing.size() == avail) {
|
||||||
valid = true;
|
valid = true;
|
||||||
for (auto & i : missing) {
|
for (auto & i : missing) {
|
||||||
auto path = i.second.path(*localStore, step->drv->name, i.first);
|
auto pathOpt = i.second.path(*localStore, step->drv->name, i.first);
|
||||||
|
assert(pathOpt); // CA derivations not yet supported
|
||||||
|
auto & path = *pathOpt;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
time_t startTime = time(0);
|
time_t startTime = time(0);
|
||||||
|
|
||||||
if (localStore->isValidPath(*path))
|
if (localStore->isValidPath(path))
|
||||||
printInfo("copying output ‘%1%’ of ‘%2%’ from local store",
|
printInfo("copying output ‘%1%’ of ‘%2%’ from local store",
|
||||||
localStore->printStorePath(*path),
|
localStore->printStorePath(path),
|
||||||
localStore->printStorePath(drvPath));
|
localStore->printStorePath(drvPath));
|
||||||
else {
|
else {
|
||||||
printInfo("substituting output ‘%1%’ of ‘%2%’",
|
printInfo("substituting output ‘%1%’ of ‘%2%’",
|
||||||
localStore->printStorePath(*path),
|
localStore->printStorePath(path),
|
||||||
localStore->printStorePath(drvPath));
|
localStore->printStorePath(drvPath));
|
||||||
localStore->ensurePath(*path);
|
localStore->ensurePath(path);
|
||||||
// FIXME: should copy directly from substituter to destStore.
|
// FIXME: should copy directly from substituter to destStore.
|
||||||
}
|
}
|
||||||
|
|
||||||
copyClosure(*localStore, *destStore,
|
copyClosure(*localStore, *destStore,
|
||||||
StorePathSet { *path },
|
StorePathSet { path },
|
||||||
NoRepair, CheckSigs, NoSubstitute);
|
NoRepair, CheckSigs, NoSubstitute);
|
||||||
|
|
||||||
time_t stopTime = time(0);
|
time_t stopTime = time(0);
|
||||||
|
@ -535,13 +539,13 @@ Step::ptr State::createStep(ref<Store> destStore,
|
||||||
{
|
{
|
||||||
auto mc = startDbUpdate();
|
auto mc = startDbUpdate();
|
||||||
pqxx::work txn(conn);
|
pqxx::work txn(conn);
|
||||||
createSubstitutionStep(txn, startTime, stopTime, build, drvPath, "out", *path);
|
createSubstitutionStep(txn, startTime, stopTime, build, drvPath, "out", path);
|
||||||
txn.commit();
|
txn.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Error & e) {
|
} catch (Error & e) {
|
||||||
printError("while copying/substituting output ‘%s’ of ‘%s’: %s",
|
printError("while copying/substituting output ‘%s’ of ‘%s’: %s",
|
||||||
localStore->printStorePath(*path),
|
localStore->printStorePath(path),
|
||||||
localStore->printStorePath(drvPath),
|
localStore->printStorePath(drvPath),
|
||||||
e.what());
|
e.what());
|
||||||
valid = false;
|
valid = false;
|
||||||
|
|
Loading…
Reference in a new issue