67f764ba93c7
build: thread ctx.passthrough into nix build argv
- time
- 2026-07-02 00:54 UTC · 3 months ago
- machine
- koh2
- agent
- claude-sonnet-5
- session
- nina passthrough flag audit
- parent
- 2bd71fb27d78
↓ nina-67f764ba.tar.gzatlas at this save
files changed3 files
src/commands.zig+2 −2src/exec.zig+11 −5src/main.zig+11 −0src/commands.zig+2 −2
@@ -931,7 +931,7 @@931931 932932 pub fn develop(ctx: Ctx) !void {933933 if (std.mem.eql(u8, ctx.sub, "show")) {934- _ = try exec.nixBuild(ctx.io, &ctx.machine, ctx.gpa, null);934+ _ = try exec.nixBuild(ctx.io, &ctx.machine, ctx.gpa, null, ctx.passthrough);935935 return;936936 }937937 const run_cmd: ?[]const u8 = if (ctx.args.len > 0 and std.mem.eql(u8, ctx.sub, "run"))@@ -1954,7 +1954,7 @@19541954 pub fn build(ctx: Ctx) !void {19551955 const attr: ?[]const u8 = if (ctx.args.len > 0) ctx.args[0] else null;19561956 output.buildStart(attr orelse "default");1957- const code = try exec.nixBuild(ctx.io, &ctx.machine, ctx.gpa, attr);1957+ const code = try exec.nixBuild(ctx.io, &ctx.machine, ctx.gpa, attr, ctx.passthrough);19581958 if (code != 0) return error.BuildFailed;19591959 output.buildDone();19601960 }src/exec.zig+11 −5
@@ -1076,13 +1076,19 @@10761076 10771077 // --- Build / Run / Develop ---10781078 1079-pub fn nixBuild(io: std.Io, machine: *const types.Machine, gpa: std.mem.Allocator, attr: ?[]const u8) !u8 {1079+pub fn nixBuild(io: std.Io, machine: *const types.Machine, gpa: std.mem.Allocator, attr: ?[]const u8, extra_flags: []const []const u8) !u8 {1080+ var argv: std.ArrayList([]const u8) = .empty;1081+ defer argv.deinit(gpa);1082+ try argv.append(gpa, "nix");1083+ try argv.append(gpa, "build");1084+ var ref_buf: ?[]u8 = null;1085+ defer if (ref_buf) |r| gpa.free(r);10801086 if (attr) |a| {1081- const ref = try std.fmt.allocPrint(gpa, ".#{s}", .{a});1082- defer gpa.free(ref);1083- return stream(io, machine, gpa, &.{ "nix", "build", ref });1087+ ref_buf = try std.fmt.allocPrint(gpa, ".#{s}", .{a});1088+ try argv.append(gpa, ref_buf.?);10841089 }1085- return stream(io, machine, gpa, &.{ "nix", "build" });1090+ try argv.appendSlice(gpa, extra_flags);1091+ return stream(io, machine, gpa, argv.items);10861092 }10871093 10881094 pub fn nixRun(io: std.Io, machine: *const types.Machine, gpa: std.mem.Allocator, pkg: []const u8) !u8 {src/main.zig+11 −0
@@ -395,6 +395,17 @@395395 try std.testing.expectEqualStrings("--all-systems", args.passthrough[0]);396396 }397397 398+test "parse args forwards build --print-build-logs" {399+ const gpa = std.testing.allocator;400+ const argv = [_][:0]const u8{ "nina", "build", "--print-build-logs" };401+ const args = try parseArgs(gpa, &argv);402+ defer gpa.free(args.rest);403+ defer gpa.free(args.passthrough);404+ try std.testing.expectEqualStrings("build", args.command);405+ try std.testing.expectEqual(@as(usize, 1), args.passthrough.len);406+ try std.testing.expectEqualStrings("--print-build-logs", args.passthrough[0]);407+}408+398409 test "parse subcommand" {399410 const gpa = std.testing.allocator;400411 const argv = [_][:0]const u8{ "nina", "service", "list" };