-
Notifications
You must be signed in to change notification settings - Fork 0
267 lines (246 loc) · 12.8 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
name: check
on:
push:
pull_request:
workflow_dispatch:
jobs:
bootstrap:
name: Bootstrap nix.conf options
runs-on: ubuntu-latest
outputs:
substituters: ${{ steps.getconf.outputs.substituters }}
trustedPublicKeys: ${{ steps.getconf.outputs.trustedPublicKeys }}
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
- id: getconf
name: Get nix.conf configuration options
run: |
nix eval '.#extra.substituters' --apply 'builtins.toString' | awk '{print "substituters="$0}' >> $GITHUB_OUTPUT
nix eval '.#extra.trusted-public-keys' --apply 'builtins.toString' | awk '{print "trustedPublicKeys="$0}' >> $GITHUB_OUTPUT
attic:
name: Build attic-client
runs-on: ubuntu-latest
needs: bootstrap
steps:
# Taken from https://github.com/lilyinstarlight/foosteros/blob/aa611d0cf03bd82f6c1c701e73f86f27abb8d8e4/.github/workflows/installer.yml
# MIT licensed
- name: Free up runner disk space
run: |
# Large docker images
sudo docker image prune --all --force
# Large packages
sudo apt-get purge -y '^llvm-.*' 'php.*' '^mongodb-.*' '^mysql-.*' azure-cli google-cloud-cli google-chrome-stable firefox powershell microsoft-edge-stable
sudo apt-get autoremove -y
sudo apt-get clean
# Large folders
sudo rm -rf /var/lib/apt/lists/* /opt/hostedtoolcache /usr/local/games /usr/local/sqlpackage /usr/local/.ghcup /usr/local/share/powershell /usr/local/share/edge_driver
sudo rm -rf /usr/local/share/gecko_driver /usr/local/share/chromium /usr/local/share/chromedriver-linux64 /usr/local/share/vcpkg /usr/local/lib/python*
sudo rm -rf /usr/local/lib/node_modules /usr/local/julia* /opt/mssql-tools /etc/skel /usr/share/vim /usr/share/postgresql /usr/share/man /usr/share/apache-maven-*
sudo rm -rf /usr/share/R /usr/share/alsa /usr/share/miniconda /usr/share/grub /usr/share/gradle-* /usr/share/locale /usr/share/texinfo /usr/share/kotlinc /usr/share/swift
sudo rm -rf /usr/share/doc /usr/share/az_9.3.0 /usr/share/sbt /usr/share/ri /usr/share/icons /usr/share/java /usr/share/fonts /usr/lib/google-cloud-sdk /usr/lib/jvm
sudo rm -rf /usr/lib/mono /usr/lib/R /usr/lib/postgresql /usr/lib/heroku /usr/lib/gcc
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
with:
extra-conf: |
extra-substituters = ${{ needs.bootstrap.outputs.substituters }}
extra-trusted-public-keys = ${{ needs.bootstrap.outputs.trustedPublicKeys }}
- uses: DeterminateSystems/magic-nix-cache-action@main
- name: Build attic
timeout-minutes: 60
run: |
nix build '.#attic-client'
nix run '.#attic-client' login --set-default ci "$ATTIC_SERVER" "$ATTIC_TOKEN"
nix-store --query --requisites --include-outputs ./result | xargs nix run '.#attic-client' -- push "ci:$ATTIC_CACHE"
env:
ATTIC_SERVER: ${{ secrets.ATTIC_SERVER }}
ATTIC_CACHE: ${{ secrets.ATTIC_CACHE }}
ATTIC_TOKEN: ${{ secrets.ATTIC_TOKEN }}
prebuild:
name: Get nixosConfiguration outputs of the flake to populate build matrix
needs: attic
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.getconfigs.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
- name: Get configurations
id: getconfigs
run: >
nix flake show --json |
jq -c '.nixosConfigurations | keys | {configuration: .}' |
awk '{print "matrix="$0}' >> $GITHUB_OUTPUT
build:
name: build nixos configurations
runs-on: ubuntu-latest
needs:
- prebuild
- bootstrap
strategy:
matrix: ${{ fromJson(needs.prebuild.outputs.matrix) }}
fail-fast: false
steps:
# Taken from https://github.com/lilyinstarlight/foosteros/blob/aa611d0cf03bd82f6c1c701e73f86f27abb8d8e4/.github/workflows/installer.yml
# MIT licensed
- name: Free up runner disk space
run: |
# Large docker images
sudo docker image prune --all --force
# Large packages
sudo apt-get purge -y '^llvm-.*' 'php.*' '^mongodb-.*' '^mysql-.*' azure-cli google-cloud-cli google-chrome-stable firefox powershell microsoft-edge-stable
sudo apt-get autoremove -y
sudo apt-get clean
# Large folders
sudo rm -rf /var/lib/apt/lists/* /opt/hostedtoolcache /usr/local/games /usr/local/sqlpackage /usr/local/.ghcup /usr/local/share/powershell /usr/local/share/edge_driver
sudo rm -rf /usr/local/share/gecko_driver /usr/local/share/chromium /usr/local/share/chromedriver-linux64 /usr/local/share/vcpkg /usr/local/lib/python*
sudo rm -rf /usr/local/lib/node_modules /usr/local/julia* /opt/mssql-tools /etc/skel /usr/share/vim /usr/share/postgresql /usr/share/man /usr/share/apache-maven-*
sudo rm -rf /usr/share/R /usr/share/alsa /usr/share/miniconda /usr/share/grub /usr/share/gradle-* /usr/share/locale /usr/share/texinfo /usr/share/kotlinc /usr/share/swift
sudo rm -rf /usr/share/doc /usr/share/az_9.3.0 /usr/share/sbt /usr/share/ri /usr/share/icons /usr/share/java /usr/share/fonts /usr/lib/google-cloud-sdk /usr/lib/jvm
sudo rm -rf /usr/lib/mono /usr/lib/R /usr/lib/postgresql /usr/lib/heroku /usr/lib/gcc
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
with:
extra-conf: |
extra-substituters = ${{ needs.bootstrap.outputs.substituters }}
extra-trusted-public-keys = ${{ needs.bootstrap.outputs.trustedPublicKeys }}
- uses: DeterminateSystems/magic-nix-cache-action@main
- name: Install and configure attic
continue-on-error: true
timeout-minutes: 20
run: |
echo ATTIC_CACHE=$ATTIC_CACHE >>$GITHUB_ENV
nix profile install '.#attic-client'
export PATH=$HOME/.nix-profile/bin:$PATH
attic login --set-default ci "$ATTIC_SERVER" "$ATTIC_TOKEN"
env:
ATTIC_SERVER: ${{ secrets.ATTIC_SERVER }}
ATTIC_CACHE: ${{ secrets.ATTIC_CACHE }}
ATTIC_TOKEN: ${{ secrets.ATTIC_TOKEN }}
- name: Build configuration ${{ matrix.configuration }}
timeout-minutes: 120
run: |
export PATH=$HOME/.nix-profile/bin:$PATH
if [[ "${{ matrix.configuration }}" =~ ^iso- ]] ; then
nix build '.#nixosConfigurations.${{ matrix.configuration }}.config.system.build.isoImage'
else
nix build '.#nixosConfigurations.${{ matrix.configuration }}.config.system.build.toplevel'
fi
nix-store --query --requisites --include-outputs ./result | xargs attic push "ci:$ATTIC_CACHE"
prebuildpkgs:
name: Get package outputs of the flake to populate build matrix
needs: attic
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.getpkgs.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
- name: Get packages
id: getpkgs
run: >
nix flake show --json |
jq -c '.packages."x86_64-linux" | keys | {package: .}' |
awk '{print "matrix="$0}' >> $GITHUB_OUTPUT
buildpkgs:
name: build nix packages
runs-on: ubuntu-latest
needs:
- prebuildpkgs
- bootstrap
strategy:
matrix: ${{ fromJson(needs.prebuildpkgs.outputs.matrix) }}
fail-fast: false
steps:
# Taken from https://github.com/lilyinstarlight/foosteros/blob/aa611d0cf03bd82f6c1c701e73f86f27abb8d8e4/.github/workflows/installer.yml
# MIT licensed
- name: Free up runner disk space
run: |
# Large docker images
sudo docker image prune --all --force
# Large packages
sudo apt-get purge -y '^llvm-.*' 'php.*' '^mongodb-.*' '^mysql-.*' azure-cli google-cloud-cli google-chrome-stable firefox powershell microsoft-edge-stable
sudo apt-get autoremove -y
sudo apt-get clean
# Large folders
sudo rm -rf /var/lib/apt/lists/* /opt/hostedtoolcache /usr/local/games /usr/local/sqlpackage /usr/local/.ghcup /usr/local/share/powershell /usr/local/share/edge_driver
sudo rm -rf /usr/local/share/gecko_driver /usr/local/share/chromium /usr/local/share/chromedriver-linux64 /usr/local/share/vcpkg /usr/local/lib/python*
sudo rm -rf /usr/local/lib/node_modules /usr/local/julia* /opt/mssql-tools /etc/skel /usr/share/vim /usr/share/postgresql /usr/share/man /usr/share/apache-maven-*
sudo rm -rf /usr/share/R /usr/share/alsa /usr/share/miniconda /usr/share/grub /usr/share/gradle-* /usr/share/locale /usr/share/texinfo /usr/share/kotlinc /usr/share/swift
sudo rm -rf /usr/share/doc /usr/share/az_9.3.0 /usr/share/sbt /usr/share/ri /usr/share/icons /usr/share/java /usr/share/fonts /usr/lib/google-cloud-sdk /usr/lib/jvm
sudo rm -rf /usr/lib/mono /usr/lib/R /usr/lib/postgresql /usr/lib/heroku /usr/lib/gcc
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
with:
extra-conf: |
extra-substituters = ${{ needs.bootstrap.outputs.substituters }}
extra-trusted-public-keys = ${{ needs.bootstrap.outputs.trustedPublicKeys }}
- uses: DeterminateSystems/magic-nix-cache-action@main
- name: Install and configure attic
timeout-minutes: 20
continue-on-error: true
run: |
echo ATTIC_CACHE=$ATTIC_CACHE >>$GITHUB_ENV
nix profile install '.#attic-client'
export PATH=$HOME/.nix-profile/bin:$PATH
attic login --set-default ci "$ATTIC_SERVER" "$ATTIC_TOKEN"
env:
ATTIC_SERVER: ${{ secrets.ATTIC_SERVER }}
ATTIC_CACHE: ${{ secrets.ATTIC_CACHE }}
ATTIC_TOKEN: ${{ secrets.ATTIC_TOKEN }}
- name: Build package ${{ matrix.package }}
timeout-minutes: 120
run: |
export PATH=$HOME/.nix-profile/bin:$PATH
nix build '.#${{ matrix.package }}'
nix-store --query --requisites --include-outputs ./result | xargs attic push "ci:$ATTIC_CACHE"
check:
name: check nix flake
needs:
- attic
- bootstrap
runs-on: ubuntu-latest
steps:
# Taken from https://github.com/lilyinstarlight/foosteros/blob/aa611d0cf03bd82f6c1c701e73f86f27abb8d8e4/.github/workflows/installer.yml
# MIT licensed
- name: Free up runner disk space
run: |
# Large docker images
sudo docker image prune --all --force
# Large packages
sudo apt-get purge -y '^llvm-.*' 'php.*' '^mongodb-.*' '^mysql-.*' azure-cli google-cloud-cli google-chrome-stable firefox powershell microsoft-edge-stable
sudo apt-get autoremove -y
sudo apt-get clean
# Large folders
sudo rm -rf /var/lib/apt/lists/* /opt/hostedtoolcache /usr/local/games /usr/local/sqlpackage /usr/local/.ghcup /usr/local/share/powershell /usr/local/share/edge_driver
sudo rm -rf /usr/local/share/gecko_driver /usr/local/share/chromium /usr/local/share/chromedriver-linux64 /usr/local/share/vcpkg /usr/local/lib/python*
sudo rm -rf /usr/local/lib/node_modules /usr/local/julia* /opt/mssql-tools /etc/skel /usr/share/vim /usr/share/postgresql /usr/share/man /usr/share/apache-maven-*
sudo rm -rf /usr/share/R /usr/share/alsa /usr/share/miniconda /usr/share/grub /usr/share/gradle-* /usr/share/locale /usr/share/texinfo /usr/share/kotlinc /usr/share/swift
sudo rm -rf /usr/share/doc /usr/share/az_9.3.0 /usr/share/sbt /usr/share/ri /usr/share/icons /usr/share/java /usr/share/fonts /usr/lib/google-cloud-sdk /usr/lib/jvm
sudo rm -rf /usr/lib/mono /usr/lib/R /usr/lib/postgresql /usr/lib/heroku /usr/lib/gcc
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
with:
extra-conf: |
extra-substituters = ${{ needs.bootstrap.outputs.substituters }}
extra-trusted-public-keys = ${{ needs.bootstrap.outputs.trustedPublicKeys }}
- uses: DeterminateSystems/magic-nix-cache-action@main
- name: Install and configure attic
timeout-minutes: 20
continue-on-error: true
run: |
echo ATTIC_CACHE=$ATTIC_CACHE >>$GITHUB_ENV
nix profile install '.#attic-client'
export PATH=$HOME/.nix-profile/bin:$PATH
attic login --set-default ci "$ATTIC_SERVER" "$ATTIC_TOKEN"
env:
ATTIC_SERVER: ${{ secrets.ATTIC_SERVER }}
ATTIC_CACHE: ${{ secrets.ATTIC_CACHE }}
ATTIC_TOKEN: ${{ secrets.ATTIC_TOKEN }}
- name: Run flake checks
run: |
export PATH=$HOME/.nix-profile/bin:$PATH
attic watch-store "ci:$ATTIC_CACHE" &
nix flake check
kill %1