From 0ec816397d2a91be41facd9905d3fbf31f3ea13c Mon Sep 17 00:00:00 2001 From: Squibid Date: Sat, 6 Dec 2025 14:53:00 -0500 Subject: [PATCH] add some docs to the nix store which may help someone with the same problems --- src/NixStore.zig | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/NixStore.zig b/src/NixStore.zig index ae71e1e..0fd66b9 100644 --- a/src/NixStore.zig +++ b/src/NixStore.zig @@ -4,6 +4,10 @@ const std = @import("std"); const gpa = std.heap.page_allocator; +/// Add a path to the store, this will copy the contents of path recursively +/// into the store and return a (hopefully) valid store path. To try and keep +/// this store path valid you should follow this with a call to realize() and +/// then root the store path. pub fn add(path: []const u8) error{Failure}![]const u8 { const res = std.process.Child.run(.{ .allocator = gpa, @@ -13,6 +17,9 @@ pub fn add(path: []const u8) error{Failure}![]const u8 { return res.stdout[0 .. res.stdout.len - 1]; // to chop off the \n } +/// This tries to tell the store that a store_path should stick around a while +/// longer, there's a chance that it doesn't listen and removes that store_path +/// but in my testing it seemed to stick around. pub fn realize(store_path: []const u8) error{Failure}!void { _ = std.process.Child.run(.{ .allocator = gpa, @@ -21,6 +28,9 @@ pub fn realize(store_path: []const u8) error{Failure}!void { return; } +/// This tells the nix store to not gc our new store_path because it has a +/// dependency at root_path and that only if root_path doesn't exist anymore +/// it can delete store_path. pub fn root(store_path: []const u8, root_path: []const u8) error{Failure}!void { _ = std.process.Child.run(.{ .allocator = gpa, @@ -29,6 +39,7 @@ pub fn root(store_path: []const u8, root_path: []const u8) error{Failure}!void { return; } +/// Delete a path from the store. pub fn delete(store_path: []const u8) error{Failure}!void { _ = std.process.Child.run(.{ .allocator = gpa,