Skip to content

Commit b770f2b

Browse files
committed
Move Garnix CI target matrix into flake checks
1 parent 142295a commit b770f2b

6 files changed

Lines changed: 122 additions & 50 deletions

File tree

CODE_MINIMAP.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,7 @@
6666

6767
- `flake.nix`
6868
- Dependency control and reproducible dev shell/build/check definitions.
69-
70-
- `garnix.yaml`
71-
- Garnix build/check configuration using flake outputs for Linux `x86_64` and `aarch64`.
69+
- Defines Garnix-facing CI checks directly in flake outputs (no `garnix.yaml`) for five targets: Linux `x86_64`/`aarch64`, macOS `aarch64`, Windows `x86_64`/`aarch64`.
7270

7371
- `.github/workflows/ci.yml`
7472
- GitHub Actions CI on `yolo`: platform matrix with Linux (`x86_64` + `aarch64`) and macOS (`aarch64`) Nix-based full test/build jobs, Windows `x86_64` native Zig test/build/smoke job, and Windows `aarch64` cross-compile artifact job.

PLAN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
- [x] Fix Compact Pro container count semantics in writer/parser (root and directory counts as full subtree entry totals) for legacy extractor compatibility. (completed 2026-02-20 16:31 EST)
2828
- [x] Fix Compact Pro header CRC coverage to include linearized entry metadata block (count/comment + all entry records) and lock with a regression unit test. (completed 2026-02-20 16:42 EST)
2929
- [x] Reproduce and fix RLE corruption around `0x81,0x81,0x81,0x82` sequences (seen in Fallout saves), with unit regression and `unar` validation against full Fallout archive. (completed 2026-02-20 16:51 EST)
30+
- [x] Remove `garnix.yaml` and move CI target selection into `flake.nix` checks (5-target matrix), plus Linux POSIX C macro fixes needed for flake cross-target builds. (completed 2026-02-20 17:02 EST)
3031

3132
## Continuity
3233

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
## CI Coverage
1313

14+
- Garnix is flake-driven (no `garnix.yaml`): it builds flake `checks` target entries.
1415
- Linux x86_64 (Nix-based full test + build)
1516
- Linux aarch64 (Nix-based full test + build)
1617
- macOS aarch64 (Nix-based full test + build)

csrc/compact_pro_cli.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
#if defined(__linux__) && !defined(_POSIX_C_SOURCE)
2+
#define _POSIX_C_SOURCE 200809L
3+
#endif
4+
#if defined(__APPLE__) && !defined(_DARWIN_C_SOURCE)
5+
#define _DARWIN_C_SOURCE
6+
#endif
7+
18
#include <errno.h>
29
#include <stdbool.h>
310
#include <stdint.h>

flake.nix

Lines changed: 112 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,120 @@
88
outputs = { self, nixpkgs }:
99
let
1010
lib = nixpkgs.lib;
11-
systems = [
11+
host_systems = [
1212
"x86_64-linux"
1313
"aarch64-linux"
1414
"x86_64-darwin"
1515
"aarch64-darwin"
1616
];
17-
forAllSystems = f: lib.genAttrs systems (system: f (import nixpkgs { inherit system; }));
17+
forAllHosts = f: lib.genAttrs host_systems (system: f (import nixpkgs { inherit system; }));
18+
19+
mkNativeCliPackage = pkgs: pkgs.stdenv.mkDerivation {
20+
pname = "compact-pro";
21+
version = "0.1.0";
22+
src = self;
23+
nativeBuildInputs = [ pkgs.zig pkgs.clang pkgs.gcc ];
24+
dontConfigure = true;
25+
buildPhase = ''
26+
runHook preBuild
27+
export ZIG_GLOBAL_CACHE_DIR="$TMPDIR/zig-global-cache"
28+
export ZIG_LOCAL_CACHE_DIR="$TMPDIR/zig-local-cache"
29+
mkdir -p "$ZIG_GLOBAL_CACHE_DIR" "$ZIG_LOCAL_CACHE_DIR"
30+
zig build -Doptimize=ReleaseFast
31+
runHook postBuild
32+
'';
33+
installPhase = ''
34+
runHook preInstall
35+
mkdir -p $out/bin
36+
cp zig-out/bin/compact-pro $out/bin/
37+
runHook postInstall
38+
'';
39+
};
40+
41+
mkCiCheck = pkgs: cfg: pkgs.stdenv.mkDerivation {
42+
pname = "compact-pro-ci-${cfg.name}";
43+
version = "0.1.0";
44+
src = self;
45+
nativeBuildInputs = [
46+
pkgs.zig
47+
pkgs.clang
48+
pkgs.gcc
49+
pkgs.bash
50+
pkgs.coreutils
51+
pkgs.diffutils
52+
pkgs.findutils
53+
pkgs.gnugrep
54+
pkgs.gnused
55+
pkgs.xxd
56+
];
57+
dontConfigure = true;
58+
buildPhase = ''
59+
runHook preBuild
60+
export ZIG_GLOBAL_CACHE_DIR="$TMPDIR/zig-global-cache"
61+
export ZIG_LOCAL_CACHE_DIR="$TMPDIR/zig-local-cache"
62+
export HOME="$TMPDIR/home"
63+
mkdir -p "$HOME"
64+
mkdir -p "$ZIG_GLOBAL_CACHE_DIR" "$ZIG_LOCAL_CACHE_DIR"
65+
'' + lib.optionalString cfg.run_tests ''
66+
zig build test -Doptimize=ReleaseFast
67+
bash tests/cli/test_cli.sh
68+
'' + ''
69+
zig build -Doptimize=ReleaseFast -Dtarget=${cfg.zig_target}
70+
runHook postBuild
71+
'';
72+
installPhase = ''
73+
mkdir -p $out
74+
echo ${cfg.zig_target} > $out/target
75+
'';
76+
};
77+
78+
ci_targets = [
79+
{
80+
name = "linux-x86_64";
81+
builder_system = "x86_64-linux";
82+
zig_target = "x86_64-linux";
83+
run_tests = true;
84+
}
85+
{
86+
name = "linux-aarch64";
87+
builder_system = "x86_64-linux";
88+
zig_target = "aarch64-linux";
89+
run_tests = false;
90+
}
91+
{
92+
name = "windows-x86_64";
93+
builder_system = "x86_64-linux";
94+
zig_target = "x86_64-windows";
95+
run_tests = false;
96+
}
97+
{
98+
name = "windows-aarch64";
99+
builder_system = "x86_64-linux";
100+
zig_target = "aarch64-windows";
101+
run_tests = false;
102+
}
103+
{
104+
name = "macos-aarch64";
105+
builder_system = "aarch64-darwin";
106+
zig_target = "aarch64-macos";
107+
run_tests = true;
108+
}
109+
];
110+
111+
ci_builder_systems = lib.unique (map (cfg: cfg.builder_system) ci_targets);
112+
checksForSystem = system:
113+
let
114+
pkgs = import nixpkgs { inherit system; };
115+
targets = lib.filter (cfg: cfg.builder_system == system) ci_targets;
116+
in
117+
lib.listToAttrs (map
118+
(cfg: {
119+
name = "ci-${cfg.name}";
120+
value = mkCiCheck pkgs cfg;
121+
})
122+
targets);
18123
in {
19-
devShells = forAllSystems (pkgs: {
124+
devShells = forAllHosts (pkgs: {
20125
default = pkgs.mkShell {
21126
packages = with pkgs; [
22127
zig
@@ -35,45 +140,11 @@
35140
};
36141
});
37142

38-
packages = forAllSystems (pkgs: {
39-
compact-pro-cli = pkgs.stdenv.mkDerivation {
40-
pname = "compact-pro";
41-
version = "0.1.0";
42-
src = self;
43-
nativeBuildInputs = [ pkgs.zig pkgs.clang pkgs.gcc ];
44-
dontConfigure = true;
45-
buildPhase = ''
46-
runHook preBuild
47-
zig build -Doptimize=ReleaseFast
48-
runHook postBuild
49-
'';
50-
installPhase = ''
51-
runHook preInstall
52-
mkdir -p $out/bin
53-
cp zig-out/bin/compact-pro $out/bin/
54-
runHook postInstall
55-
'';
56-
};
57-
default = self.packages.${pkgs.system}.compact-pro-cli;
143+
packages = forAllHosts (pkgs: {
144+
compact-pro-cli = mkNativeCliPackage pkgs;
145+
default = self.packages.${pkgs.stdenv.hostPlatform.system}.compact-pro-cli;
58146
});
59147

60-
checks = forAllSystems (pkgs: {
61-
default = pkgs.stdenv.mkDerivation {
62-
pname = "compact-pro-check";
63-
version = "0.1.0";
64-
src = self;
65-
nativeBuildInputs = [ pkgs.zig pkgs.clang pkgs.gcc pkgs.bash ];
66-
dontConfigure = true;
67-
buildPhase = ''
68-
runHook preBuild
69-
./test
70-
runHook postBuild
71-
'';
72-
installPhase = ''
73-
mkdir -p $out
74-
echo ok > $out/result
75-
'';
76-
};
77-
});
148+
checks = lib.genAttrs ci_builder_systems checksForSystem;
78149
};
79150
}

garnix.yaml

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)