Skip to content

Commit 7085048

Browse files
committed
test new approach
1 parent a0c6ff8 commit 7085048

1 file changed

Lines changed: 21 additions & 11 deletions

File tree

.github/workflows/maven.yml

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,29 @@ jobs:
1818
steps:
1919
- uses: actions/checkout@v4
2020
- uses: cachix/install-nix-action@v31
21-
- name: Evaluate Nix expressions
21+
- uses: actions/cache/restore@v4
22+
id: cache
23+
with:
24+
path: cache-closure.nar
25+
key: nix-${{ hashFiles('.github/workflows/maven.yml', 'default.nix', 'nix/**', 'pom.xml', 'local-maven-repo') }}
26+
# restore-keys:
27+
- name: Import cache
28+
if: steps.cache.outputs.cache-hit == 'true'
29+
run: |
30+
nix-store --import < cache-closure.nar
31+
- name: Build and export cache
32+
if: steps.cache.outputs.cache-hit == 'false'
2233
run: |
23-
nix-instantiate --expr '[ (import ./nix/github-workflow-dependencies.nix) (import ./default.nix)]' 2>&1 | grep '^/nix/store/' | tee derivations
24-
echo 'dry build'
25-
nix-store --realize --dry-run $(< derivations) 2>&1 | tee dry-build
26-
echo 'to be fetched'
27-
sed '1,/^these .* will be fetched/ d; s/^ //' dry-build | tee fetch
28-
echo 'to be built'
29-
sed -n '2,/^these .* will be fetched/ p' dry-build | grep -v '^these' | sed 's/ //' | tee built
30-
- name: Fetch
31-
run: nix-store --realize $(< fetch)
34+
nix-build --out-link dependencies nix/github-workflow-dependencies.nix
35+
nix-store --export $(nix-store --query --requisites dependencies) > cache-closure.nar
36+
- uses: actions/cache/save@v4
37+
if: steps.cache.outputs.cache-hit == 'false'
38+
with:
39+
path: cache-closure.nar
40+
key: nix-${{ hashFiles('.github/workflows/maven.yml', 'default.nix', 'nix/**', 'pom.xml', 'local-maven-repo') }}
41+
# restore-keys:
3242
- name: Build
33-
run: nix-store --realize $(< built)
43+
run: nix-build
3444
- name: Upload Javadoc artifact
3545
if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/main' }}
3646
uses: actions/upload-pages-artifact@v3

0 commit comments

Comments
 (0)