Zig NEWS

Discussion on: Zig Package Manager - WTF is Zon

Collapse
 
guidoschmidt profile image
Guido Schmidt

Nice introduction to zon, thanks for sharing. I was wondering if there's already the possibilty to use a local path instead of a git url for a package? For like when you want to work on your own library in parallel to a project which is using it as a package via zon.

Collapse
 
cryptocode profile image
cryptocode • Edited

Here's one way:

mod2$ tar --exclude=mod2.tar.gz --exclude='./zig-cache' --exclude='./zig-out' -zcvf  mod2.tar.gz .

mod2$ python3 -m http.server 9000

mod1$ cat build.zig.zon
.{
    .name = "test-mod2",
    .version = "0.0.1",

    .dependencies = .{
        .mod2 = .{
            .url = "http://localhost:9000/mod2.tar.gz",
            .hash = "12207ba8570a2249dda4f695dac501e0a9d2b5f22276a4bceae1f5b87f7dc0a896d1",
        },
    },
}
Enter fullscreen mode Exit fullscreen mode
Collapse
 
guidoschmidt profile image
Guido Schmidt

Ah nice, didn't thought about spinning up a local http server for this, thx :)

Thread Thread
 
cryptocode profile image
cryptocode • Edited

Most people run zig build a first time to get the Zig-compatible sha256 hash of the tar.gz file (you get the actual hash as an error)

If you wanna do it yourself, here's quick Python script I made: gist.github.com/cryptocode/7bf963c...

Thread Thread
 
guidoschmidt profile image
Guido Schmidt

404 unfortunatelly, might be a private gist 😇

Thread Thread
 
cryptocode profile image
cryptocode

Can you try again? Others seems to be able to access it.

gist.github.com/cryptocode/7bf963c...

Thread Thread
 
guidoschmidt profile image
Guido Schmidt

Thanks for checking again, works. Maybe I wasn't logged in or sth.