diff --git a/discover/action.yml b/discover/action.yml index 5236155..4212620 100644 --- a/discover/action.yml +++ b/discover/action.yml @@ -18,6 +18,9 @@ outputs: nix_conf: description: "Nix configuration of the flake." value: ${{ steps.eval.outputs.nix_conf }} + cached: + description: "Boolean marking whether results are cached in inputs.cache." + value: ${{ steps.eval.outputs.cached }} runs: using: "composite" diff --git a/discover/eval.sh b/discover/eval.sh index cff8ea7..ed1680b 100755 --- a/discover/eval.sh +++ b/discover/eval.sh @@ -61,6 +61,8 @@ function cache() { if [[ -n $drvs ]]; then #shellcheck disable=SC2086 nix copy --derivation --to "$CACHE" $drvs + + echo "cached=true" >> "$GITHUB_OUTPUT" fi echo "::endgroup::" diff --git a/run/action.yaml b/run/action.yaml index b53f6e6..7dd65c2 100644 --- a/run/action.yaml +++ b/run/action.yaml @@ -18,6 +18,9 @@ inputs: json: description: "JSON describing the action, found in the discovery phase." required: true + cached: + description: "Boolean marking whether to pull discovery artifacts from the Nix cache." + required: false extra_nix_config: description: "Configuration to append to the nix.conf." required: false @@ -42,6 +45,7 @@ runs: shell: bash - name: Restore Cache & Discovery Results + if: inputs.cached != 'true' || inputs.cache == 'auto' id: restore-cache uses: divnix/nix-cache-action@v3.0.11-nix with: @@ -61,6 +65,11 @@ runs: secret-key-files = ${{ env.NIX_KEY_PATH }} ${{ inputs.extra_nix_config }} + - name: Pull Target from Nix Cache + if: inputs.cached == 'true' && inputs.cache != 'auto' + run: nix copy --derivation --from ${{ inputs.cache }} ${{ fromJSON(env.JSON).targetDrv }} + shell: bash + - name: Build ${{ fromJSON(env.JSON).name }} id: build run: |