d00f8194f384

forward unrecognized flags like --refresh from nina flake update to nix flake update; bump v3.4.11

time
2026-07-02 00:37 UTC · 3 months ago
machine
koh2
agent
claude-sonnet-5
session
forward flake update flags
parent
762b7aa461df
4 files VERSION+1 −1src/commands.zig+3 −2src/exec.zig+7 −5src/main.zig+21 −1
VERSION+1 −1
@@ -1 +1 @@1-3.4.101+3.4.11

view file

src/commands.zig+3 −2
@@ -27,6 +27,7 @@2727     machine: types.Machine,2828     cfg: types.NinaConfig,2929     args: []const []const u8, // positional args after subcommand30+    passthrough: []const []const u8, // unrecognized flags, forwarded verbatim to the wrapped nix command3031     sub: []const u8, // subcommand (e.g. "list" in "service list")3132     dry: bool,3233     check: bool,@@ -1691,7 +1692,7 @@16911692     if (std.mem.eql(u8, ctx.sub, "update")) {16921693         output.flakeUpdateStart();16931694         const input: ?[]const u8 = if (ctx.args.len > 0) ctx.args[0] else null;1694-        _ = try exec.flakeUpdate(ctx.io, &ctx.machine, ctx.gpa, input);1695+        _ = try exec.flakeUpdate(ctx.io, &ctx.machine, ctx.gpa, input, ctx.passthrough);16951696         output.flakeLockWritten();16961697         return;16971698     }@@ -1928,7 +1929,7 @@19281929 19291930 pub fn unpin(ctx: Ctx) !void {19301931     const input = if (ctx.args.len > 0) ctx.args[0] else return error.Internal;1931-    _ = try exec.flakeUpdate(ctx.io, &ctx.machine, ctx.gpa, input);1932+    _ = try exec.flakeUpdate(ctx.io, &ctx.machine, ctx.gpa, input, &.{});19321933     output.unpinDone(input);19331934 }19341935 

view file

src/exec.zig+7 −5
@@ -1026,11 +1026,13 @@10261026 10271027 // --- Flake ---10281028 1029-pub fn flakeUpdate(io: std.Io, machine: *const types.Machine, gpa: std.mem.Allocator, input: ?[]const u8) !u8 {1030-    if (input) |inp| {1031-        return stream(io, machine, gpa, &.{ "nix", "flake", "update", inp });1032-    }1033-    return stream(io, machine, gpa, &.{ "nix", "flake", "update" });1029+pub fn flakeUpdate(io: std.Io, machine: *const types.Machine, gpa: std.mem.Allocator, input: ?[]const u8, extra_flags: []const []const u8) !u8 {1030+    var argv: std.ArrayList([]const u8) = .empty;1031+    defer argv.deinit(gpa);1032+    try argv.appendSlice(gpa, &.{ "nix", "flake", "update" });1033+    if (input) |inp| try argv.append(gpa, inp);1034+    try argv.appendSlice(gpa, extra_flags);1035+    return stream(io, machine, gpa, argv.items);10341036 }10351037 10361038 // Update flake inputs for the flake living in `dir` (the config dir). `nix flake

view file

src/main.zig+21 −1
@@ -14,6 +14,7 @@1414     command: []const u8 = "",1515     sub: []const u8 = "",1616     rest: []const []const u8 = &.{},17+    passthrough: []const []const u8 = &.{}, // unrecognized flags (e.g. --refresh), forwarded to the wrapped nix command1718     machine: ?[]const u8 = null,1819     version: bool = false,1920     dry: bool = false,@@ -80,6 +81,7 @@8081             .machine = dummy_machine,8182             .cfg = dummy_cfg,8283             .args = args.rest,84+            .passthrough = args.passthrough,8385             .sub = args.sub,8486             .dry = args.dry,8587             .check = args.check,@@ -160,6 +162,7 @@160162         .machine = machine,161163         .cfg = cfg,162164         .args = args.rest,165+        .passthrough = args.passthrough,163166         .sub = args.sub,164167         .dry = args.dry,165168         .check = args.check,@@ -257,6 +260,7 @@257260 fn parseArgs(arena: std.mem.Allocator, argv: []const [:0]const u8) !Args {258261     var result = Args{};259262     var rest: std.ArrayList([]const u8) = .empty;263+    var passthrough: std.ArrayList([]const u8) = .empty;260264     var i: usize = 1; // skip program name261265 262266     // First positional = command@@ -307,11 +311,15 @@307311             try rest.append(arena, "--dir");308312         } else if (a.len > 0 and a[0] != '-') {309313             try rest.append(arena, a);314+        } else {315+            // Unrecognized flag (e.g. --refresh) — forwarded verbatim to whatever316+            // nix command the subcommand wraps, instead of being dropped silently.317+            try passthrough.append(arena, a);310318         }311-        // Ignore unknown flags silently312319     }313320 314321     result.rest = try rest.toOwnedSlice(arena);322+    result.passthrough = try passthrough.toOwnedSlice(arena);315323     return result;316324 }317325 @@ -339,6 +347,18 @@339347     defer gpa.free(args.rest);340348     try std.testing.expectEqualStrings("status", args.command);341349     try std.testing.expectEqualStrings("build-server", args.machine.?);350+}351+352+test "parse args forwards unrecognized flags" {353+    const gpa = std.testing.allocator;354+    const argv = [_][:0]const u8{ "nina", "flake", "update", "--refresh" };355+    const args = try parseArgs(gpa, &argv);356+    defer gpa.free(args.rest);357+    defer gpa.free(args.passthrough);358+    try std.testing.expectEqualStrings("flake", args.command);359+    try std.testing.expectEqualStrings("update", args.sub);360+    try std.testing.expectEqual(@as(usize, 1), args.passthrough.len);361+    try std.testing.expectEqualStrings("--refresh", args.passthrough[0]);342362 }343363 344364 test "parse subcommand" {

view file