add some docs to the nix store which may help someone with the same problems

This commit is contained in:
Squibid 2025-12-06 14:53:00 -05:00
parent 8cf6029872
commit 0ec816397d
Signed by: squibid
GPG key ID: BECE5684D3C4005D

View file

@ -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,