bigbox2 as cache machine approach #1
This commit is contained in:
1 parent
4535f9eb91
commit
6dd651d156
7 files changed
+52
-7
No files matched your search
@@ -0,0 +1,35 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
let
|
||||
cfg = config.skyg.nixos.common.cachePush;
|
||||
in
|
||||
{
|
||||
options.skyg.nixos.common.cachePush = {
|
||||
enable = lib.mkEnableOption "push finished builds to the bigbox2 binary cache";
|
||||
url = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "http://bigbox2.lab.internal:5000";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
# Push every finished build to the cache right after it finishes.
|
||||
nix.settings.post-build-hook = pkgs.writeShellScript "nix-post-build-hook" ''
|
||||
set -u
|
||||
if [ -n "''${OUT_PATHS:-}" ]; then
|
||||
nix copy --to "${cfg.url}" $OUT_PATHS \
|
||||
|| echo "post-build-hook: failed to push to ${cfg.url}" >&2
|
||||
fi
|
||||
'';
|
||||
|
||||
# Manual/backstop push command, available on every host's PATH.
|
||||
environment.systemPackages = [
|
||||
(pkgs.writeShellScriptBin "push-cache" ''
|
||||
set -eu
|
||||
if [ "''$#" -eq 0 ]; then
|
||||
set -- /run/current-system
|
||||
fi
|
||||
exec nix copy --to "${cfg.url}" "''$@"
|
||||
'')
|
||||
];
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user