Run uploads in the background, to speed builds
This commit is contained in:
@@ -40,17 +40,30 @@ with lib;
|
|||||||
greg.tailscale.enable = true;
|
greg.tailscale.enable = true;
|
||||||
|
|
||||||
# The builder user needs to be trusted to submit builds
|
# The builder user needs to be trusted to submit builds
|
||||||
nix.settings = {
|
nix.settings =
|
||||||
post-build-hook = getExe (
|
let
|
||||||
|
upload = getExe (
|
||||||
pkgs.writeShellScriptBin "upload-to-cache.sh" ''
|
pkgs.writeShellScriptBin "upload-to-cache.sh" ''
|
||||||
set -eu
|
set -eu
|
||||||
set -f
|
set -f
|
||||||
export AWS_SHARED_CREDENTIALS_FILE=${config.age.secrets.cache-credentials.path}
|
export AWS_SHARED_CREDENTIALS_FILE=${config.age.secrets.cache-credentials.path}
|
||||||
export IFS=' '
|
export IFS=' '
|
||||||
echo "Uploading paths " $OUT_PATHS
|
${getExe config.nix.package} copy --to "s3://binary-cache/?scheme=http&endpoint=nas.home%3A9000&profile=default" "$@"
|
||||||
nix copy --to "s3://binary-cache/?scheme=http&endpoint=nas.home%3A9000&profile=default" $OUT_PATHS
|
|
||||||
''
|
''
|
||||||
);
|
);
|
||||||
|
uploadRunner = getExe (
|
||||||
|
pkgs.writeShellScriptBin "uploade-to-cache-runner.sh" ''
|
||||||
|
${lib.getExe' config.systemd.package "systemd-run"} \
|
||||||
|
--unit "upload-$(${lib.getExe' pkgs.coreutils "date"} +%s%3N)" \
|
||||||
|
--property Type=exec \
|
||||||
|
--property CollectMode=inactive \
|
||||||
|
--property Group=nixbld \
|
||||||
|
${upload} $OUT_PATHS
|
||||||
|
''
|
||||||
|
);
|
||||||
|
in
|
||||||
|
{
|
||||||
|
post-build-hook = uploadRunner;
|
||||||
secret-key-files = config.age.secrets.private-cache.path;
|
secret-key-files = config.age.secrets.private-cache.path;
|
||||||
trusted-users = [ config.users.users.remote-builder-user.name ];
|
trusted-users = [ config.users.users.remote-builder-user.name ];
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user