-
Notifications
You must be signed in to change notification settings - Fork 2
210 lines (177 loc) · 6.79 KB
/
ci.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
name: Build and test flake outputs
on:
push:
workflow_dispatch:
workflow_call:
inputs:
branch:
description: Branch name to build on
default: ""
required: false
type: string
secrets:
CACHIX_ACTIVATE_TOKEN:
CACHIX_AUTH_TOKEN:
required: true
jobs:
nix:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
system:
- aarch64
- x86_64
nix-command:
- fmt -- --check
- eval .#apps.$_system.nixos-shell.program
- eval .#apps.$_system.setup.program
include:
- nix-command: develop .#jdk8 --profile profile
system: x86_64
- nix-command: develop .#jdk11 --profile profile
system: x86_64
- nix-command: develop .#jdk17 --profile profile
system: x86_64
- nix-command: develop .#php74 --profile profile
system: x86_64
- nix-command: develop .#php74-composer1 --profile profile
system: x86_64
- nix-command: develop .#php80 --profile profile
system: x86_64
- nix-command: develop .#php81 --profile profile
system: x86_64
- nix-command: build .#homeConfigurations."tobias@gamer".activationPackage
system: x86_64
- nix-command: build .#nixOnDroidConfigurations.pixel7a.activationPackage --impure
system: aarch64
- nix-command: build .#nixosConfigurations.argon.config.system.build.toplevel
system: aarch64
deploy-agent: argon
- nix-command: build .#nixosConfigurations.krypton.config.system.build.toplevel
system: x86_64
deploy-agent: krypton
- nix-command: build .#nixosConfigurations.neon.config.system.build.toplevel
system: x86_64
deploy-agent: neon
deploy-args: --async
- nix-command: build .#nixosConfigurations.xenon.config.system.build.toplevel
system: aarch64
deploy-agent: xenon
- nix-command: build .#packages.$_system.rpi-firmware
system: aarch64
- nix-command: build .#packages.$_system.rpi-image
system: aarch64
- nix-command: build .#packages.$_system.installer-image
system: x86_64
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
continue-on-error: true
with:
tool-cache: true
- name: Install nix
uses: cachix/install-nix-action@v23
with:
extra_nix_config: |
keep-going = true
- name: Setup cachix
uses: cachix/cachix-action@v12
with:
name: gerschtli
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
- name: Build command (aarch64)
if: matrix.system == 'aarch64'
# FIXME: use upstream once --tty is removed
#uses: uraimo/run-on-arch-action@v2
uses: Gerschtli/run-on-arch-action@tty
with:
arch: aarch64
distro: alpine_latest
githubToken: ${{ github.token }}
dockerRunArgs: --volume /nix:/nix
install: |
apk --no-cache add curl git xz
adduser --disabled-password ci
env: |
_system: ${{ matrix.system }}-linux
CACHIX_ACTIVATE_TOKEN: ${{ secrets.CACHIX_ACTIVATE_TOKEN || 'no-value' }}
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
mkdir -p /home/ci/.config/nix
cat <<EOF > /home/ci/.config/nix/nix.conf
experimental-features = nix-command flakes
keep-going = true
show-trace = true
access-tokens = github.com=$GITHUB_TOKEN
EOF
chown --recursive ci:ci /nix /home/ci
chgrp --recursive ci "$(pwd)"
chmod -R g+w "$(pwd)"
echo "::group::Install nix"
curl \
--silent \
--show-error \
--output /tmp/install \
--retry 5 \
--retry-all-errors \
--fail \
--location \
"https://nixos.org/nix/install"
su ci -c "sh /tmp/install --no-channel-add --no-daemon"
rm /tmp/install
function run() {
su ci -c ". /home/ci/.nix-profile/etc/profile.d/nix.sh; $*"
}
# FIXME: setting build-hook is needed because default hook `nix __build-remote` is not available
function build_hook() {
local nix_path="$(run which nix)"
echo "${nix_path/bin\/nix/libexec/nix/build-remote}"
}
run echo "build-hook = $(build_hook)" >> /home/ci/.config/nix/nix.conf
echo "::group::Setup cachix"
run nix-env --quiet -j8 -iA cachix -f https://cachix.org/api/v1/install
run cachix --version
run cachix use gerschtli
run cachix use nix-on-droid
echo "::group::Build command"
run git config --global --add safe.directory "$(pwd)"
run nix ${{ matrix.nix-command }}
${{ github.ref == 'refs/heads/master' && inputs.branch == '' && matrix.deploy-agent &&
format(
'
echo "::group::Build spec"
spec="$(run nix build --print-out-paths ".#cachix-deploy-spec-{0}")"
echo "::group::Upload spec"
run cachix push gerschtli "$spec"
echo "::group::Activate deployment"
run cachix deploy activate --agent "{0}" {1} "$spec"
',
matrix.deploy-agent,
matrix.deploy-args
)
|| 'echo "::group::Skip spec deploy"'
}}
- name: Build command (x86_64)
if: matrix.system == 'x86_64'
env:
_system: ${{ matrix.system }}-linux
run: nix ${{ matrix.nix-command }}
- name: Deploy cachix-agent spec (x86_64)
if: matrix.system == 'x86_64' && github.ref == 'refs/heads/master' && inputs.branch == '' && matrix.deploy-agent
env:
CACHIX_ACTIVATE_TOKEN: ${{ secrets.CACHIX_ACTIVATE_TOKEN }}
run: |
echo "::group::Build spec"
spec="$(nix build --print-out-paths ".#cachix-deploy-spec-${{ matrix.deploy-agent }}")"
echo "::group::Upload spec"
cachix push gerschtli "$spec"
echo "::group::Activate deployment"
cachix deploy activate --agent "${{ matrix.deploy-agent }}" ${{ matrix.deploy-args }} "$spec"
# vim: set sw=2: