diff --git a/src/NixStore.zig b/src/NixStore.zig index fbbaed4..ae71e1e 100644 --- a/src/NixStore.zig +++ b/src/NixStore.zig @@ -4,41 +4,37 @@ const std = @import("std"); const gpa = std.heap.page_allocator; -const NixStoreError = error{ - Failure, -}; - -pub fn add(path: []const u8) NixStoreError![]const u8 { +pub fn add(path: []const u8) error{Failure}![]const u8 { const res = std.process.Child.run(.{ .allocator = gpa, .argv = &[_][]const u8{ "nix", "store", "add", path }, - }) catch return NixStoreError.Failure; + }) catch return error.Failure; return res.stdout[0 .. res.stdout.len - 1]; // to chop off the \n } -pub fn realize(store_path: []const u8) NixStoreError!void { +pub fn realize(store_path: []const u8) error{Failure}!void { _ = std.process.Child.run(.{ .allocator = gpa, .argv = &[_][]const u8{ "nix-store", "--realize", store_path }, - }) catch return NixStoreError.Failure; + }) catch return error.Failure; return; } -pub fn root(store_path: []const u8, root_path: []const u8) NixStoreError!void { +pub fn root(store_path: []const u8, root_path: []const u8) error{Failure}!void { _ = std.process.Child.run(.{ .allocator = gpa, .argv = &[_][]const u8{ "nix-store", "--add-root", root_path, "--indirect", store_path }, - }) catch return NixStoreError.Failure; + }) catch return error.Failure; return; } -pub fn delete(store_path: []const u8) NixStoreError!void { +pub fn delete(store_path: []const u8) error{Failure}!void { _ = std.process.Child.run(.{ .allocator = gpa, .argv = &[_][]const u8{ "nix", "store", "delete", store_path }, }) catch { - return NixStoreError.Failure; + return error.Failure; }; return; } diff --git a/src/main.zig b/src/main.zig index 55423a5..aacd242 100644 --- a/src/main.zig +++ b/src/main.zig @@ -102,7 +102,7 @@ pub fn main() !void { // delete the old nix store path if (dest_old_store_path) |path| { std.log.info("deleting old store path: {s}", .{path}); - NixStore.delete(path) catch |err| if (err == error.Failure) return err; + try NixStore.delete(path); } }