@@ -0,0 +1,70 @@
1+name: Nix S3 cache
2+description: Enable Nix build path recording and upload recorded paths to an S3 binary cache.
3+
4+inputs:
5+ operation:
6+ description: "Operation to run: enable-recorder or upload."
7+ required: true
8+ aws-role-to-assume:
9+ description: AWS IAM role to assume before uploading Nix paths.
10+ required: false
11+ aws-region:
12+ description: AWS region for the Nix cache upload role.
13+ required: false
14+ default: us-east-1
15+ role-duration-seconds:
16+ description: AWS role duration for the Nix cache upload role.
17+ required: false
18+ default: "21600"
19+ cache-private-key:
20+ description: Private signing key for the Nix binary cache.
21+ required: false
22+ cache-s3-store-url:
23+ description: Nix S3 store URL used as the nix copy destination.
24+ required: false
25+
26+runs:
27+ using: composite
28+ steps:
29+ - name: Validate operation
30+ shell: bash
31+ env:
32+ OPERATION: ${{ inputs.operation }}
33+ run: |
34+ set -euo pipefail
35+
36+ case "$OPERATION" in
37+ enable-recorder|upload) ;;
38+ *)
39+ echo "Unsupported operation: $OPERATION" >&2
40+ echo "Expected one of: enable-recorder, upload" >&2
41+ exit 1
42+ ;;
43+ esac
44+
45+ - name: Enable Nix remote cache path recorder
46+ if: ${{ inputs.operation == 'enable-recorder' }}
47+ shell: bash
48+ run: bash "$GITHUB_ACTION_PATH/enable-recorder.sh"
49+
50+ - name: Configure AWS credentials for Nix cache upload
51+ if: ${{ inputs.operation == 'upload' }}
52+ uses: aws-actions/configure-aws-credentials@v6
53+ with:
54+ role-to-assume: ${{ inputs.aws-role-to-assume }}
55+ aws-region: ${{ inputs.aws-region }}
56+ role-duration-seconds: ${{ inputs.role-duration-seconds }}
57+
58+ - name: Upload built Nix paths to S3 cache
59+ if: ${{ inputs.operation == 'upload' }}
60+ shell: bash
61+ env:
62+ NIX_CACHE_PRIVATE_KEY: ${{ inputs.cache-private-key }}
63+ NIX_CACHE_S3_STORE_URL: ${{ inputs.cache-s3-store-url }}
64+ run: bash "$GITHUB_ACTION_PATH/upload.sh"
65+
66+ - name: Clean up Nix S3 cache files
67+ if: ${{ always() && inputs.operation == 'upload' }}
68+ shell: bash
69+ run: bash "$GITHUB_ACTION_PATH/cleanup.sh"
70+