Skip to content

Commit 03f1f20

Browse files
committed
Add Nix caching
Makes the CI automatically push the binaries of all clash-* apps and developer shells to the caches.
1 parent be91e18 commit 03f1f20

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed

.github/workflows/nix-cache.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Upload to caches
2+
3+
on:
4+
push:
5+
branches:
6+
# - main
7+
8+
concurrency:
9+
group: ${{ github.head_ref || github.run_id }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
packages:
14+
name: Push package to local cache
15+
runs-on: self-hosted
16+
strategy:
17+
matrix:
18+
clash-app: [
19+
"clash-benchmark",
20+
"clash-prelude-hedgehog",
21+
"clash-cosim",
22+
"clash-profiling",
23+
"clash-ffi",
24+
"clash-profiling-prepare",
25+
"clash-ghc",
26+
"clash-term",
27+
"clash-lib",
28+
"clash-testsuite",
29+
"clash-lib-hedgehog",
30+
"clash-prelude"
31+
]
32+
steps:
33+
- name: Checkout
34+
uses: actions/checkout@v4
35+
36+
- name: Build & test
37+
run: |
38+
# The -L flag outputs build logs to stderr
39+
nix build -L .#${{ matrix.clash-app }}
40+
41+
- name: Push package to cache
42+
env:
43+
ATTIC_TOKEN: ${{ secrets.ATTIC_SECRET }}
44+
run: |
45+
attic login --set-default public http://192.168.102.136:9200/ "$ATTIC_TOKEN"
46+
attic push public $(nix path-info .#${{ matrix.clash-app }})
47+
48+
- name: Push package to cachix
49+
env:
50+
CACHIX_TOKEN: ${{ secrets.CACHIX_SECRET }}
51+
run: |
52+
cachix authtoken $CACHIX_TOKEN
53+
nix path-info .#${{ matrix.clash-app }} | cachix push clash-lang
54+
55+
devshells:
56+
name: Push Nix developer shell to local cache
57+
runs-on: self-hosted
58+
strategy:
59+
matrix:
60+
ghc-version: [ "ghc9101", "ghc982", "ghc964" ]
61+
steps:
62+
# There's no need to configure Nix, the dockerfile handling the GHA has it done for us!
63+
# If a dependencies are already cached, we can simply re-use them!
64+
65+
- name: Checkout
66+
uses: actions/checkout@v4
67+
68+
- name: Build devshell
69+
run: |
70+
# Since the server is x86_64-linux, we can only build the devshell
71+
# for that
72+
nix build .#devShells.x86_64-linux.${{ matrix.ghc-version }}
73+
74+
# Pushes the binaries to the local network
75+
# url: http://192.168.102.136:9200/public
76+
# public key: public:PGGlJMx1gGmU069blMqve8tS1ndzBuriUAwGBHGOo4g=
77+
- name: Push devshell to cache
78+
env:
79+
ATTIC_TOKEN: ${{ secrets.ATTIC_SECRET }}
80+
run: |
81+
attic login --set-default public http://192.168.102.136:9200/ "$ATTIC_TOKEN"
82+
attic push public $(nix path-info .#devShells.x86_64-linux.${{ matrix.ghc-version }})
83+
84+
# Pushes the binaries to Cachix
85+
- name: Push devshell to cachix
86+
env:
87+
CACHIX_TOKEN: ${{ secrets.CACHIX_SECRET }}
88+
run: |
89+
cachix authtoken $CACHIX_TOKEN
90+
nix path-info .#devShells.x86_64-linux.${{ matrix.ghc-version }} | cachix push clash-lang
91+

0 commit comments

Comments
 (0)