nix-community / zon2nix

Convert the dependencies in `build.zig.zon` to a Nix expression [maintainer=@figsoda]
https://discourse.nixos.org/t/31468
Mozilla Public License 2.0
71 stars 10 forks source link

Support `git+` dependencies. #11

Open LordMZTE opened 7 months ago

LordMZTE commented 7 months ago

Zig supports pulling packages from git with this syntax in a dependencies' .url field: git+https://git.mzte.de/mirrors/zig-args.git#89f18a104d9c13763b90e97d6b4ce133da8a3e2b.

zon2nix will naively prepend tarball+ here, resulting in a completely invalid URL for nix flake prefetch. We can fix this by detecting the git+ prefix and converting this to a valid URL for nix, which in my example would be: git+https://git.mzte.de/mirrors/zig-args.git?rev=89f18a104d9c13763b90e97d6b4ce133da8a3e2b.

In the generated deps.nix, we'd then also have to use fetchgit instead of fetchzip. The generated code would look like this in my example:

{
  name = "12203ded54c85878eea7f12744066dcb4397177395ac49a7b2aa365bf6047b623829";
  path = fetchgit {
    url = "https://git.mzte.de/mirrors/zig-args.git";
    rev = "89f18a104d9c13763b90e97d6b4ce133da8a3e2b";
    hash = "sha256-JY0UDJSKOh1Cg46/GnhVTNmgr6TJKoHXgt8FponPCPM=";
  };
}
matdibu commented 5 days ago

I'll give this a go