Skip to content

Commit b857843

Browse files
committed
tools: add workflow to review Nix changes
1 parent b2f6aa3 commit b857843

2 files changed

Lines changed: 130 additions & 2 deletions

File tree

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: Review Nix changes
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- '**.nix'
7+
- '.github/workflows/review-nix-changes.yml'
8+
types: [opened, synchronize, reopened, ready_for_review]
9+
push:
10+
branches:
11+
- main
12+
- canary
13+
- v[0-9]+.x-staging
14+
- v[0-9]+.x
15+
paths:
16+
- '**.nix'
17+
- '.github/workflows/review-nix-changes.yml'
18+
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
21+
cancel-in-progress: true
22+
23+
permissions:
24+
contents: read
25+
26+
jobs:
27+
eval:
28+
strategy:
29+
fail-fast: false
30+
matrix:
31+
include:
32+
- runner: ubuntu-24.04
33+
system: x86_64-linux
34+
- runner: ubuntu-24.04-arm
35+
system: aarch64-linux
36+
# - runner: macos-15-intel
37+
# system: x86_64-darwin
38+
# - runner: macos-latest
39+
# system: aarch64-darwin
40+
name: '${{ matrix.system }}: Evaluate shell.nix'
41+
runs-on: ${{ matrix.runner }}
42+
steps:
43+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
44+
with:
45+
persist-credentials: false
46+
sparse-checkout: '*.nix'
47+
sparse-checkout-cone-mode: false
48+
fetch-depth: 2
49+
50+
- uses: cachix/install-nix-action@96951a368ba55167b55f1c916f7d416bac6505fe # v31.10.3
51+
with:
52+
extra_nix_config: sandbox = true
53+
54+
- uses: cachix/cachix-action@1eb2ef646ac0255473d23a5907ad7b04ce94065c # v17
55+
with:
56+
name: nodejs
57+
58+
- name: Compare
59+
run: |
60+
NIX_DIR=./tools/nix
61+
nix_show_derivation () {
62+
nix --extra-experimental-features nix-command derivation show $2 "$1"
63+
}
64+
list_nix_derivations () {
65+
DRV="$(
66+
nix-instantiate -I "nixpkgs=$NIX_DIR/pkgs.nix" "./shell.nix" \
67+
--arg devTools "
68+
(import $NIX_DIR/devTools.nix {})
69+
++ builtins.attrValues (
70+
{ inherit (import <nixpkgs> {}) nixfmt-tree sccache; }
71+
// import $NIX_DIR/openssl-matrix.nix {}
72+
)" \
73+
--arg withTemporal true \
74+
--arg withQuic true
75+
)"
76+
nix-store -qR --include-outputs "$DRV" | sort -k1.45 > "out/${{ matrix.system }}-$1-paths.txt"
77+
nix_show_derivation "$DRV" -r | jq '(
78+
.derivations |= (
79+
to_entries
80+
| sort_by(.key | .[32:])
81+
| .[].value.inputs.drvs |= (
82+
to_entries
83+
| sort_by(.key | .[32:])
84+
| from_entries)
85+
| from_entries))' > "out/${{ matrix.system }}-$1-drv.json"
86+
}
87+
mkdir out
88+
list_nix_derivations after
89+
git reset HEAD^ --hard
90+
list_nix_derivations before
91+
92+
- name: Upload tarball artifact
93+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
94+
with:
95+
path: out/
96+
name: diff-${{ matrix.system }}
97+
98+
compare:
99+
runs-on: ubuntu-slim
100+
needs: eval
101+
permissions:
102+
pull-requests: write
103+
steps:
104+
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
105+
106+
- run: tree || ls
107+
108+
- name: Add comment
109+
run: |
110+
{
111+
echo "This PR touches some Nix files. To help review it, here's a quick overview of the changes that were detected:"
112+
113+
for system in x86_64-linux aarch64-linux x86_64-darwin aarch64-darwin; do
114+
echo
115+
echo "<details><summary>$system</summary>"
116+
echo
117+
echo '```diff'
118+
diff "diff-$system/$system-before-paths.txt" "diff-$system/$system-after-paths.txt" || true
119+
echo '```'
120+
echo
121+
echo "</details>"
122+
done
123+
124+
echo
125+
echo "To dig deeper, please review manually the JSON files."
126+
} #| gh pr comment "$PR_URL" --edit-last --create-if-none -F-
127+
128+

tools/nix/pkgs.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
arg:
22
let
33
repo = "https://github.com/NixOS/nixpkgs";
4-
rev = "01fbdeef22b76df85ea168fbfe1bfd9e63681b30";
4+
rev = "c6d65881c5624c9cae5ea6cedef24699b0c0a4c0";
55
nixpkgs = import (builtins.fetchTarball {
66
url = "${repo}/archive/${rev}.tar.gz";
7-
sha256 = "0b76m4i1sn0dg78ylapvbkgw9knkf6lm1lss39w6zyshgv1rbi0q";
7+
sha256 = "1yf4qv3scjygdkg67nibrhbddg3154mv9cxffvykmwcrwfcrrlaq";
88
}) arg;
99
in
1010
nixpkgs

0 commit comments

Comments
 (0)