Skip to content

Commit bf269d7

Browse files
Introduce development Nix binary cache (#3911)
* Desktop: Introduce development Nix binary cache * Configure caches in CI * Cache nix shell * Fix
1 parent a99b280 commit bf269d7

File tree

3 files changed

+62
-11
lines changed

3 files changed

+62
-11
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ on:
2020
linux:
2121
description: "Linux"
2222
type: boolean
23-
push_to_nix_cache:
24-
description: "Linux: push to Nix cache"
25-
type: boolean
2623
debug:
2724
description: "Debug build"
2825
type: boolean
@@ -36,8 +33,6 @@ on:
3633
type: boolean
3734
linux:
3835
type: boolean
39-
push_to_nix_cache:
40-
type: boolean
4136
debug:
4237
type: boolean
4338
checkout_repo:
@@ -639,6 +634,10 @@ jobs:
639634

640635
- name: ❄ Install Nix
641636
uses: DeterminateSystems/nix-installer-action@main
637+
with:
638+
extra-conf: |
639+
extra-substituters = https://graphite.cachix.org https://graphite-dev.cachix.org
640+
extra-trusted-public-keys = graphite.cachix.org-1:B7Il1yMpkquN/dXM+5GRmz+4Xmu2aaCS1GcWNfFhsOo= graphite-dev.cachix.org-1:RppXYpiV1qO2TYKTkXXGHsAEQDOB5G51b3VlrN9QmbI=
642641
643642
- name: 🗑 Free disk space
644643
run: sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache
@@ -647,12 +646,12 @@ jobs:
647646
run: nix build .#graphite${{ inputs.debug && '-dev' || '' }} --no-link --print-out-paths
648647

649648
- name: 📤 Push to Nix cache
650-
if: (github.event_name == 'push' || inputs.push_to_nix_cache) && !inputs.debug
651649
env:
652-
NIX_CACHE_AUTH_TOKEN: ${{ secrets.NIX_CACHE_AUTH_TOKEN }}
650+
NIX_CACHE_AUTH_TOKEN: ${{ (!inputs.debug && github.ref == 'refs/heads/master') && secrets.NIX_CACHE_AUTH_TOKEN || secrets.NIX_CACHE_AUTH_TOKEN_DEV }}
651+
NIX_CACHE_NAME: ${{ (!inputs.debug && github.ref == 'refs/heads/master') && 'graphite' || 'graphite-dev' }}
653652
run: |
654653
nix run nixpkgs#cachix -- authtoken $NIX_CACHE_AUTH_TOKEN
655-
nix build --no-link --print-out-paths | nix run nixpkgs#cachix -- push graphite
654+
nix build .#graphite${{ inputs.debug && '-dev' || '' }} --no-link --print-out-paths | nix run nixpkgs#cachix -- push $NIX_CACHE_NAME
656655
657656
- name: 🏗 Build Linux bundle
658657
run: nix build .#graphite${{ inputs.debug && '-dev' || '' }}-bundle.tar.xz && cp ./result ./graphite-linux-bundle.tar.xz

.github/workflows/nix.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: "Nix Housekeeping"
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
workflow_dispatch: {}
8+
9+
jobs:
10+
cache-dev-shell:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
15+
steps:
16+
- name: 📥 Clone repository
17+
uses: actions/checkout@v6
18+
with:
19+
repository: ${{ inputs.checkout_repo || github.repository }}
20+
ref: ${{ inputs.checkout_ref || '' }}
21+
22+
- name: ❄ Install Nix
23+
uses: DeterminateSystems/nix-installer-action@main
24+
with:
25+
extra-conf: |
26+
extra-substituters = https://graphite.cachix.org https://graphite-dev.cachix.org
27+
extra-trusted-public-keys = graphite.cachix.org-1:B7Il1yMpkquN/dXM+5GRmz+4Xmu2aaCS1GcWNfFhsOo= graphite-dev.cachix.org-1:RppXYpiV1qO2TYKTkXXGHsAEQDOB5G51b3VlrN9QmbI=
28+
29+
- name: 🔎 Check whether development shell is already in binary cache
30+
id: cache-check
31+
run: |
32+
out_path="$(nix eval --raw .#devShells.x86_64-linux.default.outPath)"
33+
if nix path-info --store https://graphite-dev.cachix.org "$out_path" &>/dev/null; then
34+
echo "cached=true" >> "$GITHUB_OUTPUT"
35+
echo "Development shell is already cached at $out_path"
36+
else
37+
echo "cached=false" >> "$GITHUB_OUTPUT"
38+
echo "Development shell is not cached"
39+
fi
40+
41+
- name: 📦 Build Nix development shell
42+
if: steps.cache-check.outputs.cached == 'false'
43+
run: nix build .#devShells.x86_64-linux.default --no-link --print-out-paths
44+
45+
- name: 📤 Push Nix development shell to binary cache
46+
if: steps.cache-check.outputs.cached == 'false'
47+
env:
48+
NIX_CACHE_AUTH_TOKEN: ${{ secrets.NIX_CACHE_AUTH_TOKEN_DEV }}
49+
run: |
50+
nix run nixpkgs#cachix -- authtoken $NIX_CACHE_AUTH_TOKEN
51+
nix build .#devShells.x86_64-linux.default --no-link --print-out-paths | nix run nixpkgs#cachix -- push graphite-dev

.github/workflows/provide-shaders.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ jobs:
1717

1818
- name: ❄ Install Nix
1919
uses: DeterminateSystems/nix-installer-action@main
20-
21-
- name: 💾 Set up Nix cache
22-
uses: DeterminateSystems/magic-nix-cache-action@main
20+
with:
21+
extra-conf: |
22+
extra-substituters = https://graphite.cachix.org https://graphite-dev.cachix.org
23+
extra-trusted-public-keys = graphite.cachix.org-1:B7Il1yMpkquN/dXM+5GRmz+4Xmu2aaCS1GcWNfFhsOo= graphite-dev.cachix.org-1:RppXYpiV1qO2TYKTkXXGHsAEQDOB5G51b3VlrN9QmbI=
2324
2425
- name: 🏗 Build graphene raster nodes shaders
2526
run: nix build .#graphite-raster-nodes-shaders && cp result raster_nodes_shaders_entrypoint.wgsl

0 commit comments

Comments
 (0)