Skip to content

Commit 5cd8ebd

Browse files
committed
update zon2nix
Upstream is now mostly pure Zig and the build.zig.zon.* files are generated directly by zon2nix. The JSON file is no longer used as an intermediate file but is retained for downstream packager usage.
1 parent 3bc2b02 commit 5cd8ebd

10 files changed

+331
-306
lines changed

.gitattributes

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
build.zig.zon.nix linguist-generated=true
22
build.zig.zon.txt linguist-generated=true
3-
build.zig.zon2json-lock linguist-generated=true
3+
build.zig.zon.json linguist-generated=true
44
vendor/** linguist-vendored
55
website/** linguist-documentation
66
pkg/breakpad/vendor/** linguist-vendored

.github/workflows/update-colorschemes.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ jobs:
6666
commit-message: "deps: Update iTerm2 color schemes"
6767
add-paths: |
6868
build.zig.zon
69-
build.zig.zon2json-lock
7069
build.zig.zon.nix
7170
build.zig.zon.txt
71+
build.zig.zon.json
7272
body: |
7373
Upstream revision: https://github.com/mbadolato/iTerm2-Color-Schemes/tree/${{ steps.zig_fetch.outputs.upstream_rev }}
7474
labels: dependencies

build.zig.zon2json-lock build.zig.zon.json

+115-115
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.zig.zon.nix

+146-148
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.lock

+17-17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
};
2626
};
2727

28-
zig2nix = {
29-
url = "github:jcollie/zig2nix?ref=c2a24405298373123e12ca81805e436da648aaf5";
28+
zon2nix = {
29+
url = "github:jcollie/zon2nix?ref=56c159be489cc6c0e73c3930bd908ddc6fe89613";
3030
inputs = {
3131
nixpkgs.follows = "nixpkgs-unstable";
3232
flake-utils.follows = "flake-utils";
@@ -39,7 +39,7 @@
3939
nixpkgs-unstable,
4040
nixpkgs-stable,
4141
zig,
42-
zig2nix,
42+
zon2nix,
4343
...
4444
}:
4545
builtins.foldl' nixpkgs-stable.lib.recursiveUpdate {} (
@@ -51,7 +51,7 @@
5151
devShell.${system} = pkgs-stable.callPackage ./nix/devShell.nix {
5252
zig = zig.packages.${system}."0.14.0";
5353
wraptest = pkgs-stable.callPackage ./nix/wraptest.nix {};
54-
zig2nix = zig2nix;
54+
zon2nix = zon2nix;
5555
};
5656

5757
packages.${system} = let

nix/build-support/check-zig-cache.sh

+40-14
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#
99
# - build.zig.zon.nix
1010
# - build.zig.zon.txt
11-
# - build.zig.zon2json-lock
11+
# - build.zig.zon.json
1212
#
1313
# All of these are auto-generated and should not be edited manually.
1414

@@ -34,45 +34,71 @@ help() {
3434
echo "commit, and submit a PR with the update:"
3535
echo ""
3636
echo " ./nix/build-support/check-zig-cache-hash.sh --update"
37-
echo " git add build.zig.zon.nix"
38-
echo " git commit -m \"nix: update build.zig.zon.nix\""
37+
echo " git add build.zig.zon.nix build.zig.zon.txt build.zig.zon.json"
38+
echo " git commit -m \"nix: update build.zig.zon.nix build.zig.zon.txt build.zig.zon.json\""
3939
echo ""
4040
}
4141

4242
ROOT="$(realpath "$(dirname "$0")/../../")"
4343
BUILD_ZIG_ZON="$ROOT/build.zig.zon"
44-
BUILD_ZIG_ZON_LOCK="$ROOT/build.zig.zon2json-lock"
4544
BUILD_ZIG_ZON_NIX="$ROOT/build.zig.zon.nix"
4645
BUILD_ZIG_ZON_TXT="$ROOT/build.zig.zon.txt"
46+
BUILD_ZIG_ZON_JSON="$ROOT/build.zig.zon.json"
4747

4848
if [ -f "${BUILD_ZIG_ZON_NIX}" ]; then
49-
OLD_HASH=$(sha512sum "${BUILD_ZIG_ZON_NIX}" | awk '{print $1}')
49+
OLD_HASH_NIX=$(sha512sum "${BUILD_ZIG_ZON_NIX}" | awk '{print $1}')
5050
elif [ "$1" != "--update" ]; then
5151
echo -e "\nERROR: build.zig.zon.nix missing."
5252
help
5353
exit 1
5454
fi
5555

56-
rm -f "$BUILD_ZIG_ZON_LOCK"
57-
zon2nix "$BUILD_ZIG_ZON" > "$WORK_DIR/build.zig.zon.nix"
56+
if [ -f "${BUILD_ZIG_ZON_TXT}" ]; then
57+
OLD_HASH_TXT=$(sha512sum "${BUILD_ZIG_ZON_TXT}" | awk '{print $1}')
58+
elif [ "$1" != "--update" ]; then
59+
echo -e "\nERROR: build.zig.zon.txt missing."
60+
help
61+
exit 1
62+
fi
63+
64+
if [ -f "${BUILD_ZIG_ZON_JSON}" ]; then
65+
OLD_HASH_JSON=$(sha512sum "${BUILD_ZIG_ZON_JSON}" | awk '{print $1}')
66+
elif [ "$1" != "--update" ]; then
67+
echo -e "\nERROR: build.zig.zon.json missing."
68+
help
69+
exit 1
70+
fi
71+
72+
zon2nix "$BUILD_ZIG_ZON" --nix "$WORK_DIR/build.zig.zon.nix" --txt "$WORK_DIR/build.zig.zon.txt" --json "$WORK_DIR/build.zig.zon.json"
5873
alejandra --quiet "$WORK_DIR/build.zig.zon.nix"
74+
prettier --write "$WORK_DIR/build.zig.zon.json"
5975

60-
NEW_HASH=$(sha512sum "$WORK_DIR/build.zig.zon.nix" | awk '{print $1}')
76+
NEW_HASH_NIX=$(sha512sum "$WORK_DIR/build.zig.zon.nix" | awk '{print $1}')
77+
NEW_HASH_TXT=$(sha512sum "$WORK_DIR/build.zig.zon.txt" | awk '{print $1}')
78+
NEW_HASH_JSON=$(sha512sum "$WORK_DIR/build.zig.zon.json" | awk '{print $1}')
6179

62-
if [ "${OLD_HASH}" == "${NEW_HASH}" ]; then
80+
if [ "${OLD_HASH_NIX}" == "${NEW_HASH_NIX}" ] && [ "${OLD_HASH_TXT}" == "${NEW_HASH_TXT}" ] && [ "${OLD_HASH_JSON}" == "${NEW_HASH_JSON}" ]; then
6381
echo -e "\nOK: build.zig.zon.nix unchanged."
82+
echo -e "OK: build.zig.zon.txt unchanged."
83+
echo -e "OK: build.zig.zon.json unchanged."
6484
exit 0
6585
elif [ "$1" != "--update" ]; then
66-
echo -e "\nERROR: build.zig.zon.nix needs to be updated."
67-
echo ""
68-
echo " * Old hash: ${OLD_HASH}"
69-
echo " * New hash: ${NEW_HASH}"
86+
echo -e "\nERROR: build.zig.zon.nix, build.zig.zon.txt, or build.zig.zon.json needs to be updated.\n"
87+
echo " * Old build.zig.zon.nix hash: ${OLD_HASH_NIX}"
88+
echo " * New build.zig.zon.nix hash: ${NEW_HASH_NIX}"
89+
echo " * Old build.zig.zon.txt hash: ${OLD_HASH_TXT}"
90+
echo " * New build.zig.zon.txt hash: ${NEW_HASH_TXT}"
91+
echo " * Old build.zig.zon.json hash: ${OLD_HASH_JSON}"
92+
echo " * New build.zig.zon.json hash: ${NEW_HASH_JSON}"
7093
help
7194
exit 1
7295
else
73-
jq -r '.[] .url' "$BUILD_ZIG_ZON_LOCK" | LANG=C sort > "$BUILD_ZIG_ZON_TXT"
7496
mv "$WORK_DIR/build.zig.zon.nix" "$BUILD_ZIG_ZON_NIX"
7597
echo -e "\nOK: build.zig.zon.nix updated."
98+
mv "$WORK_DIR/build.zig.zon.txt" "$BUILD_ZIG_ZON_TXT"
99+
echo -e "OK: build.zig.zon.txt updated."
100+
mv "$WORK_DIR/build.zig.zon.json" "$BUILD_ZIG_ZON_JSON"
101+
echo -e "OK: build.zig.zon.json updated."
76102
exit 0
77103
fi
78104

nix/build-support/fetch-zig-cache.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ then
1616
fi
1717

1818
# Go through each line of our build.zig.zon.txt and fetch it.
19-
SCRIPT_PATH="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
19+
SCRIPT_PATH="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd)"
2020
ZON_TXT_FILE="$SCRIPT_PATH/../../build.zig.zon.txt"
2121
while IFS= read -r url; do
2222
echo "Fetching: $url"

nix/devShell.nix

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
wayland,
6262
wayland-scanner,
6363
wayland-protocols,
64-
zig2nix,
64+
zon2nix,
6565
system,
6666
}: let
6767
# See package.nix. Keep in sync.
@@ -113,7 +113,7 @@ in
113113
scdoc
114114
zig
115115
zip
116-
zig2nix.packages.${system}.zon2nix
116+
zon2nix.packages.${system}.zon2nix
117117

118118
# For web and wasm stuff
119119
nodejs

typos.toml

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ extend-exclude = [
33
# Build
44
"build.zig.zon",
55
"build.zig.zon.nix",
6-
"build.zig.zon2json-lock",
6+
"build.zig.zon.txt",
7+
"build.zig.zon.json",
78
# vendored code
89
"vendor/*",
910
"pkg/*",
@@ -23,14 +24,14 @@ extend-exclude = [
2324
"*.pdf",
2425
"*.data",
2526
"*.xib",
26-
"src/cli/lorem_ipsum.txt"
27+
"src/cli/lorem_ipsum.txt",
2728
]
2829

2930
[default]
3031
extend-ignore-re = [
3132
# Ignore typos in test expectations
3233
"testing\\.expect[^;]*;",
33-
"kHOM\\d*"
34+
"kHOM\\d*",
3435
]
3536

3637
[default.extend-words]

0 commit comments

Comments
 (0)