Giter VIP home page Giter VIP logo

zon2nix's Introduction

zon2nix

Convert the dependencies in build.zig.zon to a Nix expression

Usage

zon2nix > deps.nix
zon2nix zls > deps.nix
zon2nix zls/build.zig.zon > deps.nix

To use the generated file, add this to your Nix expression:

postPatch = ''
  ln -s ${callPackage ./deps.nix { }} $ZIG_GLOBAL_CACHE_DIR/p
'';

Example

This build.zig.zon from zls

.{
    .name = "zls",
    .version = "0.11.0",

    .dependencies = .{
        .known_folders = .{
            .url = "https://github.com/ziglibs/known-folders/archive/fa75e1bc672952efa0cf06160bbd942b47f6d59b.tar.gz",
            .hash = "122048992ca58a78318b6eba4f65c692564be5af3b30fbef50cd4abeda981b2e7fa5",
        },
        .diffz = .{
            .url = "https://github.com/ziglibs/diffz/archive/90353d401c59e2ca5ed0abe5444c29ad3d7489aa.tar.gz",
            .hash = "122089a8247a693cad53beb161bde6c30f71376cd4298798d45b32740c3581405864",
        },
        .binned_allocator = .{
            .url = "https://gist.github.com/antlilja/8372900fcc09e38d7b0b6bbaddad3904/archive/6c3321e0969ff2463f8335da5601986cf2108690.tar.gz",
            .hash = "1220363c7e27b2d3f39de6ff6e90f9537a0634199860fea237a55ddb1e1717f5d6a5",
        },
    },
}

produces the following nix expression

# generated by zon2nix (https://github.com/nix-community/zon2nix)

{ linkFarm, fetchzip }:

linkFarm "zig-packages" [
  {
    name = "1220363c7e27b2d3f39de6ff6e90f9537a0634199860fea237a55ddb1e1717f5d6a5";
    path = fetchzip {
      url = "https://gist.github.com/antlilja/8372900fcc09e38d7b0b6bbaddad3904/archive/6c3321e0969ff2463f8335da5601986cf2108690.tar.gz";
      hash = "sha256-m/kr4kmkG2rLkAj5YwvM0HmXTd+chAiQHzYK6ozpWlw=";
    };
  }
  {
    name = "122048992ca58a78318b6eba4f65c692564be5af3b30fbef50cd4abeda981b2e7fa5";
    path = fetchzip {
      url = "https://github.com/ziglibs/known-folders/archive/fa75e1bc672952efa0cf06160bbd942b47f6d59b.tar.gz";
      hash = "sha256-U/h4bVarq8CFKbFyNXKl3vBRPubYooLxA1xUz3qMGPE=";
    };
  }
  {
    name = "122089a8247a693cad53beb161bde6c30f71376cd4298798d45b32740c3581405864";
    path = fetchzip {
      url = "https://github.com/ziglibs/diffz/archive/90353d401c59e2ca5ed0abe5444c29ad3d7489aa.tar.gz";
      hash = "sha256-3CdYo6WevT0alRwKmbABahjhFKz7V9rdkDUZ43VtDeU=";
    };
  }
]

zon2nix's People

Contributors

dependabot[bot] avatar figsoda avatar grahamc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

zon2nix's Issues

Support `git+` dependencies.

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=";
  };
}

Runtime error

Hi.

When running nix run github:nix-community/zon2nix I get the following error:

error: parseError
???:?:?: 0x218eb0 in ??? ()
???:?:?: 0x21ec7a in ??? ()

I'm running it in the ZLS's master branch on NixOS unstable.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.