1# The execution platform: the prelude's own default (local execution on the 2# host's cpu/os) plus an OPT-IN remote action cache. 3# 4# prelude//platforms:default hard-codes local-only execution, so no 5# [buck2_re_client] config can make it use a cache. This rule is that same 6# platform with `remote_cache` exposed. BUCK sets it from `[buildbuddy] cache`, 7# which only the dev machine's user-level buckconfig provides 8# (nixos-config modules/buildbuddy.nix, ~/.buckconfig.d/buildbuddy, together 9# with the endpoint and key). Anywhere that file is absent (CI, another 10# machine) the flag is false and this is exactly the prelude default, so the 11# repo never needs the cache or its credentials to build. 12# 13# Cache-only: actions always run locally; the cache is checked first and local 14# results are uploaded. Measured 2026-09-23: a clean rebuild and a second 15# checkout at another path both hit 100%. Kept identical across the estate's 16# buck2 repos on purpose; change it everywhere or nowhere. 17 18load("@prelude//cfg/exec_platform:marker.bzl", "get_exec_platform_marker") 19 20def _cached_execution_platform_impl(ctx: AnalysisContext) -> list[Provider]: 21 constraints = dict() 22 constraints.update(ctx.attrs.cpu_configuration[ConfigurationInfo].constraints) 23 constraints.update(ctx.attrs.os_configuration[ConfigurationInfo].constraints) 24 cfg = ConfigurationInfo(constraints = constraints, values = {}) 25 26 name = ctx.label.raw_target() 27 platform = ExecutionPlatformInfo( 28 label = name, 29 configuration = cfg, 30 executor_config = CommandExecutorConfig( 31 local_enabled = True, 32 remote_enabled = False, 33 remote_cache_enabled = ctx.attrs.remote_cache, 34 allow_cache_uploads = ctx.attrs.remote_cache, 35 use_windows_path_separators = ctx.attrs.use_windows_path_separators, 36 ), 37 ) 38 39 return [ 40 DefaultInfo(), 41 platform, 42 PlatformInfo(label = str(name), configuration = cfg), 43 ExecutionPlatformRegistrationInfo( 44 platforms = [platform], 45 exec_marker_constraint = get_exec_platform_marker(), 46 ), 47 ] 48 49cached_execution_platform = rule( 50 impl = _cached_execution_platform_impl, 51 attrs = { 52 "cpu_configuration": attrs.dep(providers = [ConfigurationInfo]), 53 "os_configuration": attrs.dep(providers = [ConfigurationInfo]), 54 "remote_cache": attrs.bool(), 55 "use_windows_path_separators": attrs.bool(), 56 }, 57)