It is planned for projects to have IDs and versions to handle this better in the future: https://github.com/ziglang/zig/issues/14288
For now, you can add the dependency to your build.zig.zon with the exact same url and hash and call b.dependency() on it with the exact same arguments and it will resolve to the same dependency:
In your build.zig.zon:
.dependencies = .{
.tokamak = .{ ... },
.httpz = .{
// make sure this url and hash are the same as the one in tokmak's build.zig.zon, and update this when you update tokmak
.url = "git+https://github.com/karlseguin/http.zig?ref=master#6e45041ef1e0ed8d3e36e15ccb459a3392571f7f",
.hash = "1220c47311099ba5705d906d11927bc222e9562830bcc32b6d638e10124371f4eeb6",
},
},
In your build.zig:
const tkm = b.dependency("tokamak", .{ .target = target, .optimize = optimize });
// make sure the arguments passed in ".{ }" are the same that tokamak passes to httpz in its build.zig
const httpz = b.dependency("httpz", .{ .target = target, .optimize = optimize });
As long as the hashes are the same and the arguments passed to b.dependency() are the same, b.dependency() will return the same pointer in your project as it does in httpz.
Alternatively, you can instead extract the httpz dependency out of tokamak's builder instead of copying it into your own build.zig.zon:
const tkm = b.dependency("tokamak", .{ .target = target, .optimize = optimize });
// make sure the arguments passed in ".{ }" are the same that tokamak passes to httpz in its build.zig
const httpz = tkm.builder.dependency("httpz", .{ .target = target, .optimize = optimize });