7d2118a61798
fix pkg size returning blank: resolve nixpkgs#<pkg> (bare name isn't a valid installable) and report human-readable closure size
- time
- 2026-06-04 23:14 UTC · 4 months ago
- machine
- koh2
- agent
- claude-opus-4-8
- session
- pkg size resolution
- parent
- adfd556a21fb
↓ nina-7d2118a6.tar.gzatlas at this save
files changed1 file
src/exec.zig+15 −6src/exec.zig+15 −6
@@ -635,13 +635,22 @@635635 }636636 637637 pub fn pkgSize(gpa: std.mem.Allocator, io: std.Io, machine: *const types.Machine, pkg: []const u8) ![]u8 {638- const r = try capture(gpa, io, machine, &.{ "nix", "path-info", "-s", pkg });638+ // A bare name ("ripgrep") isn't a valid installable; resolve via nixpkgs# like639+ // `pkg path` does. -S -h gives closure size, human-readable. Output is640+ // "<store-path> <size>"; return just the size.641+ const ref = try std.fmt.allocPrint(gpa, "nixpkgs#{s}", .{pkg});642+ defer gpa.free(ref);643+ const r = try capture(gpa, io, machine, &.{ "nix", "path-info", "-S", "-h", ref });639644 defer gpa.free(r.stderr);640- if (r.exit_code != 0) {641- gpa.free(r.stdout);642- return error.ProcessFailed;643- }644- return r.stdout;645+ defer gpa.free(r.stdout);646+ if (r.exit_code != 0) return error.ProcessFailed;647+648+ const line = std.mem.trim(u8, r.stdout, " \t\n\r");649+ var it = std.mem.tokenizeAny(u8, line, " \t");650+ _ = it.next(); // store path651+ const size = std.mem.trim(u8, it.rest(), " \t");652+ if (size.len == 0) return error.ProcessFailed;653+ return gpa.dupe(u8, size);645654 }646655 647656 pub fn pkgClosure(io: std.Io, machine: *const types.Machine, gpa: std.mem.Allocator, pkg: []const u8) !u8 {