generated from nix-community/nur-packages-template
-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (134 loc) · 5.46 KB
/
build.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
name: "Build and populate cache"
on:
workflow_dispatch: # allows manual triggering
pull_request:
push:
branches:
- main
- master
schedule:
# rebuild everyday at 3:30
# TIP: Choose a random time here so not all repositories are build at once:
# https://www.random.org/clock-times/?num=1&earliest=01%3A00&latest=08%3A00&interval=5&format=html&rnd=new
- cron: '30 3 * * *'
jobs:
define-matrix:
name: Define job matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
steps:
- name: Define matrix
id: matrix
run: |
jq -nrf /dev/stdin << 'EOF' > "$GITHUB_OUTPUT"
"Rhys-T" as $nurRepo |
"rhys-t" as $cachixName |
[
"Lnx x64/ubuntu-latest",
"Lnx A64/ubuntu-latest+qemu-aarch64-linux",
"Mac x64/macos-13",
"Mac A64/macos-latest",
empty] as $runners |
[
"nixpkgs-unstable",
"nixos-unstable",
"nixos-24.05",
"nixos-24.11",
"ce40ce79f14469fd17dfe41c9b51490495d3f99e",
empty] as $nixpkgss |
[
"base",
"mame",
"hbmame",
"qemu-screamer",
empty] as $subsets |
{include: [
$runners[] as $runner |
$nixpkgss[] as $nixpkgs |
(if $nixpkgs | test("^[0-9a-f]{40}$") then $nixpkgs else "refs/heads/\($nixpkgs)" end) as $nixpkgsPath |
($runner | split("/")) as [$displayRunner, $runner] |
select(($runner | startswith("ubuntu")) or ($nixpkgs | startswith("nixos") | not)) |
($runner | split("+qemu-")) as [$runner, $qemuSystem] |
(if $qemuSystem then {
"aarch64-linux": "arm64",
}[$qemuSystem] else null end) as $qemuSystemForAction |
# (if $qemuSystem then $subsets[] else "all" end) as $subset |
$subsets[] as $subset |
select(($runner | startswith("macos")) or ($subset != "mame")) |
($nixpkgs |
gsub("^nixpkgs-"; "NP-") |
gsub("^nixos-"; "NO-") |
gsub("-unstable$"; "-U") |
.) as $displayNixpkgs |
{$displayRunner, $runner, $qemuSystem, $qemuSystemForAction, $displayNixpkgs, $nixpkgs, $nixpkgsPath, $subset, $nurRepo, $cachixName}
]} |
@json "matrix=\(.)"
EOF
tests:
needs: define-matrix
strategy:
matrix: ${{ fromJson(needs.define-matrix.outputs.matrix) }}
fail-fast: false
name: ${{ matrix.displayRunner }} ${{ matrix.displayNixpkgs }} ${{ matrix.subset }}
runs-on: ${{ matrix.runner }}
outputs:
nurRepo: ${{ steps.build.outputs.nurRepo }}
steps:
- name: Output nurRepo for final job
run: echo 'nurRepo=${{ matrix.nurRepo }}' >> "$GITHUB_OUTPUT"
- name: Checkout repository
uses: actions/checkout@v4
- name: Install qemu-user-static
if: ${{ matrix.qemuSystem != null }}
uses: docker/setup-qemu-action@v3
with:
platforms: ${{ matrix.qemuSystemForAction }}
- name: Install nix
uses: cachix/install-nix-action@v30
with:
nix_path: "nixpkgs=https://github.com/NixOS/nixpkgs/archive/${{ matrix.nixpkgsPath }}.tar.gz"
extra_nix_config: |
experimental-features = nix-command flakes
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
${{ matrix.qemuSystem && format('extra-platforms = {0}', matrix.qemuSystem)}}
- name: Show nixpkgs version
run: nix-instantiate --eval -E '(import <nixpkgs> {}).lib.version'
- name: Setup cachix
uses: cachix/cachix-action@v15
# Don't replace <YOUR_CACHIX_NAME> here!
if: ${{ matrix.cachixName != '<YOUR_CACHIX_NAME>' }}
with:
name: ${{ matrix.cachixName }}
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Check evaluation
run: |
nix-env -f . -qa \* --meta --xml \
--allowed-uris https://static.rust-lang.org \
--option restrict-eval true \
--option allow-import-from-derivation true \
--drv-path --show-trace \
-I nixpkgs=$(nix-instantiate --find-file nixpkgs) \
-I $PWD
- name: Build nix packages
id: build
run: nix shell -f '<nixpkgs>' nix-build-uncached -c nix-build-uncached ci.nix -build-flags '-L --keep-going' ${{ matrix.qemuSystem && format('--argstr platform {0}', matrix.qemuSystem) }} --argstr subsetName ${{ matrix.subset }} -A cacheOutputs
- name: Upload build logs
if: '!cancelled()'
uses: actions/upload-artifact@v4
with:
name: Rhys-T-nur-packages-build-logs-${{ matrix.runner }}${{ matrix.qemuSystem && format('+qemu-{0}', matrix.qemuSystem) }}-${{ matrix.nixpkgs }}-${{ matrix.subset }}
path: |
/nix/var/log
!/nix/var/log/nix/drvs/*/*user-environment*
if-no-files-found: ignore
trigger-update:
name: Trigger NUR update
runs-on: ubuntu-latest
needs: tests
steps:
- name: Trigger NUR update
# Don't replace <YOUR_REPO_NAME> here!
if: ${{ needs.tests.outputs.nurRepo != '<YOUR_REPO_NAME>' }}
run: curl -XPOST "https://nur-update.nix-community.org/update?repo=${{ needs.tests.outputs.nurRepo }}"