89cc9bd8035f
home back: rollback via home-manager switch --rollback — homeBack parses home generations (newest-first), takes gen[0]=current and gen[1]=target, confirms, runs 'home-manager switch --rollback'; <2 generations prints 'already at the oldest generation' instead of failing; build+tests green
- time
- 2026-06-10 01:25 UTC · 4 months ago
- machine
- koh2
- agent
- claude-opus-4-8
- session
- flake + home manager support
- parent
- ee5a921daea4
↓ nina-89cc9bd8.tar.gzatlas at this save
files changed1 file
src/commands.zig+23 −0src/commands.zig+23 −0
@@ -944,7 +944,30 @@944944 return;945945 }946946 947+ if (std.mem.eql(u8, ctx.sub, "back")) return homeBack(ctx);948+947949 return output.subcommandHelp("home", &home_help, null);950+}951+952+fn homeBack(ctx: Ctx) !void {953+ const out = try exec.homeGenerations(ctx.gpa, ctx.io, &ctx.machine);954+ defer ctx.gpa.free(out);955+ const gens = try parseHomeGenerations(ctx.gpa, out);956+ defer freeHomeGens(ctx.gpa, gens);957+958+ // Newest-first: [0] is current, [1] is the generation to roll back to.959+ if (gens.len < 2) {960+ output.alreadyOldest();961+ return;962+ }963+ const current = gens[0].number;964+ const prev = gens[1].number;965+966+ output.homeBackStart(ctx.machine.name, current, prev);967+ if (ctx.cfg.confirm and !output.confirm("")) return;968+ const code = try exec.homeManagerRollback(ctx.io, &ctx.machine, ctx.gpa);969+ if (code != 0) return error.BuildFailed;970+ output.homeBackDone(prev);948971 }949972 950973 fn homeApply(ctx: Ctx, mode: exec.HomeManagerMode) !void {