e54614fcd2b5

home diff: diff between home manager generations — homeDiff parses the two newest home generations and runs nix store diff-closures on their store paths via exec.diffClosuresPaths (tty streams native color, piped path captures+strips ANSI like system diff); <2 generations prints 'nothing to diff yet'; build+tests green

time
2026-06-10 01:27 UTC · 4 months ago
machine
koh2
agent
claude-opus-4-8
session
flake + home manager support
parent
55d6ea4397d0
2 files src/commands.zig+19 −0src/output.zig+4 −0
src/commands.zig+19 −0
@@ -949,8 +949,27 @@949949     if (std.mem.eql(u8, ctx.sub, "back")) return homeBack(ctx);950950     if (std.mem.eql(u8, ctx.sub, "history")) return homeHistory(ctx);951951     if (std.mem.eql(u8, ctx.sub, "check")) return homeCheck(ctx);952+    if (std.mem.eql(u8, ctx.sub, "diff")) return homeDiff(ctx);952953 953954     return output.subcommandHelp("home", &home_help, null);955+}956+957+fn homeDiff(ctx: Ctx) !void {958+    const out = try exec.homeGenerations(ctx.gpa, ctx.io, &ctx.machine);959+    defer ctx.gpa.free(out);960+    const gens = try parseHomeGenerations(ctx.gpa, out);961+    defer freeHomeGens(ctx.gpa, gens);962+963+    // Need two generations and both their store paths to diff their closures.964+    if (gens.len < 2 or gens[0].path.len == 0 or gens[1].path.len == 0) {965+        output.homeNothingToDiff();966+        return;967+    }968+    const newer = gens[0];969+    const older = gens[1];970+    output.homeDiffHeader(older.number, newer.number, ctx.machine.name);971+    if (try exec.diffClosuresPaths(ctx.io, &ctx.machine, ctx.gpa, older.path, newer.path) != 0)972+        return error.ProcessFailed;954973 }955974 956975 fn homeCheck(ctx: Ctx) !void {

view file

src/output.zig+4 −0
@@ -1034,6 +1034,10 @@10341034     p("{s}home gen {d} -> gen {d}  {s}\n\n", .{ hdr(), a, b, machine });10351035 }10361036 1037+pub fn homeNothingToDiff() void {1038+    p("{s}only one home generation — nothing to diff yet\n", .{hdr()});1039+}1040+10371041 pub fn homePackagesHeader(machine: []const u8) void {10381042     p("{s}home packages  {s}\n\n", .{ hdr(), machine });10391043 }

view file