f41c183586ea
update/upgrade: auto-detect flake vs channel and use correct path — nina upgrade now updates flake inputs (exec.flakeUpdateAt: cd config dir && nix flake update) on a flake system instead of nix-channel --update, then rebuilds (rebuild already flake-aware); channel path unchanged for channel systems. NOTE: in this codebase 'nina update' is the kepr binary self-updater, so the channel-vs-flake branch lives in 'upgrade' (the channel-update+rebuild command); flake-system note for plain channel ops is shown by 'nina channel'. build+tests green
- time
- 2026-06-10 01:30 UTC · 4 months ago
- machine
- koh2
- agent
- claude-opus-4-8
- session
- flake + home manager support
- parent
- c35b8c5bbfb7
↓ nina-f41c1835.tar.gzatlas at this save
files changed2 files
src/commands.zig+10 −2src/exec.zig+7 −0src/commands.zig+10 −2
@@ -460,8 +460,16 @@460460 461461 pub fn upgrade(ctx: Ctx) !void {462462 output.upgradeStart(ctx.machine.name);463- output.printSubstep("updating channels", .{});464- _ = exec.channelUpdate(ctx.io, &ctx.machine, ctx.gpa) catch {};463+ // Flake systems update inputs (flake.lock); channel systems update channels.464+ // Running nix-channel --update on a flake system is a no-op at best. The465+ // rebuild below is already flake-aware via exec.nixosRebuildSwitch.466+ if (flakeSystem(ctx)) {467+ output.printSubstep("updating flake inputs", .{});468+ _ = exec.flakeUpdateAt(ctx.io, &ctx.machine, ctx.gpa, ctx.machine.config_path) catch {};469+ } else {470+ output.printSubstep("updating channels", .{});471+ _ = exec.channelUpdate(ctx.io, &ctx.machine, ctx.gpa) catch {};472+ }465473 output.printSubstep("rebuilding", .{});466474 const start = std.Io.Clock.awake.now(ctx.io);467475 const code = try exec.nixosRebuildSwitch(ctx.io, &ctx.machine, ctx.gpa);src/exec.zig+7 −0
@@ -744,6 +744,13 @@744744 return stream(io, machine, gpa, &.{ "nix", "flake", "update" });745745 }746746 747+// Update flake inputs for the flake living in `dir` (the config dir). `nix flake748+// update` operates on the flake in the working directory, so we cd there first.749+// Used by `nina upgrade` on a flake system in place of nix-channel --update.750+pub fn flakeUpdateAt(io: std.Io, machine: *const types.Machine, gpa: std.mem.Allocator, dir: []const u8) !u8 {751+ return stream(io, machine, gpa, &.{ "sh", "-c", "cd \"$0\" && nix flake update", dir });752+}753+747754 pub fn flakeCheck(io: std.Io, machine: *const types.Machine, gpa: std.mem.Allocator) !u8 {748755 return stream(io, machine, gpa, &.{ "nix", "flake", "check" });749756 }