{"id":25621664,"url":"https://github.com/jeansidharta/nix-zon-parser","last_synced_at":"2026-05-17T03:35:53.270Z","repository":{"id":278802172,"uuid":"936827141","full_name":"Jeansidharta/nix-zon-parser","owner":"Jeansidharta","description":"A nix library to parse build.zig.zon files into a nix expression","archived":false,"fork":false,"pushed_at":"2025-02-21T19:05:18.000Z","size":0,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-21T19:39:46.627Z","etag":null,"topics":["nix","zig","ziglang"],"latest_commit_sha":null,"homepage":"","language":"Nix","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Jeansidharta.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-21T18:56:30.000Z","updated_at":"2025-02-21T19:05:21.000Z","dependencies_parsed_at":"2025-02-21T19:39:49.645Z","dependency_job_id":"85136bf0-e3d8-4394-9337-c9ec855715c0","html_url":"https://github.com/Jeansidharta/nix-zon-parser","commit_stats":null,"previous_names":["jeansidharta/nix-zon-parser"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jeansidharta%2Fnix-zon-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jeansidharta%2Fnix-zon-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jeansidharta%2Fnix-zon-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jeansidharta%2Fnix-zon-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Jeansidharta","download_url":"https://codeload.github.com/Jeansidharta/nix-zon-parser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240152874,"owners_count":19756149,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nix","zig","ziglang"],"created_at":"2025-02-22T09:37:04.214Z","updated_at":"2026-05-17T03:35:53.225Z","avatar_url":"https://github.com/Jeansidharta.png","language":"Nix","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Zon parser to Nix expression\n\nThis is a function to conver a `.zon` expression to a nix value. `.zon` files are related to the [zig](https://ziglang.org/) language and are mainly used to declare project metadata, such as version, name, and dependencies.\n\n## Motivation\n\nCurrently there are very few tools to package zig projects in nix. The main issue is zig's dependencies. During build, zig will try to fetch any missing dependencies from the internet; however, since nix builds are pure, they don't have internet access. Therefore, if we want to package a zig project, we must fetch it ourselves before zig build, and provide these packages to zig using the `zig build --system \u003cPREFETCHED_DEPENDENCIES\u003e` command.\n\nThe manual way of doing it is to create a nix flake and populate its inputs with the project's dependencies. We then need to patch `build.zig.zon` to point to our fetched dependency, instead of a URL.\n\nWith this project, we could instead read the project's dependencies during evaluation, and automatically fetch theses dependencies using [`fetchurl`](https://nixos.org/manual/nixpkgs/stable/#sec-pkgs-fetchers-fetchurl) with the correct hash and version. It would then be very painless to maintain a flake for any zig project.\n\n## Usage\n\nThe recomended way of using this is through flakes. Simply add this into your inputs and use its `parse` output:\n```nix\n{\n    inputs.nix-zon-parser.url = \"github:Jeansidharta/nix-zon-parser\";\n    outputs = { nix-zon-parser, ... }: let\n        parsed = nix-zon-parser.parse (builtins.readFile ./build.zig.zon);\n        inherit (parsed) name version dependencies;\n\n        # You can then use these variables to create your derivation\n    in {\n        # Rest of your flake\n    };\n}\n```\n\n## Issues\n\nThe project is not currently very robust. It is not very well tested, and might give weird results if the zon file is not correctly formated. This project is not meant to validate a zon file, but instead to read data from a valid zon file. Therefore, it assumes the file is correctly formated while parsing it. If you encounter any issues using it, please open an issue.\n\n## Testing\n\nThe `test.sh` script should run all automated tests.\n\n## Comparison with Zon2nix\n\n[zon2nix](https://github.com/nix-community/zon2nix) is a project that is similar in spirit, but has a very different purpose.\n\nzon2nix is a CLI script that will take a `build.zig.zon` file as an argument and spit in stdout a nix expression with all of the file's dependencies. Since it's a CLI application, it cannot be used by nix to fetch the project's dependencies at runtime. The user must first manually call `zon2nix build.zig.zon \u003e dependencies.nix` an then import these dependencies in their derivation script. Another issue is that zon2nix only cares about the dependencies, and so it cannot be used to fetch othe metadata, such as the project name or version.\n\nThis project is a parser entirely written in nix. This means it is significantly slower than zon2nix, but it allows us to use the information in `build.zig.zon` to make a derivation. The user can then do things like\n\n```nix\n{\n    parsedBuild = parse (builtins.readFile ./build.zig.zon);\n    projectName = parsedBuild.name;\n    projectVersion = parsedBuild.version;\n    projectDependencies = parsedBuild.dependencies;\n}\n```\n\n## Contributing\n\nIf you wish to open an issue or a PR, feel free to do so. I'll do my best to respond in a timely manner.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeansidharta%2Fnix-zon-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjeansidharta%2Fnix-zon-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeansidharta%2Fnix-zon-parser/lists"}