Skip to content

Commit

Permalink
Remove zon2nix
Browse files Browse the repository at this point in the history
  • Loading branch information
accelbread committed Oct 25, 2024
1 parent 9d7c9ff commit 50250df
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ path.

Sets `package` to the zig project at the flake source.

Adds `zig`, `zls`, and `zon2nix` to the default devShell.
Adds `zig` and `zls` to the default devShell.

Adds checks for zig tests.

Expand All @@ -40,17 +40,27 @@ Configures `zig` files to be formatted with `zig fmt`.

### When `build.zig.zon` has dependencies

Use `zon2nix` to generate `deps.nix`.

The `zon2nix` output can be used as follows:
Configure `zigDependencies` to a package containing the Zig package cache to
use. This is a directory tree with each package in a directory named by the Zig
package hash. For example:

```nix
{
description = "My Zig application.";
inputs.flakelight-zig.url = "github:accelbread/flakelight-zig";
outputs = { flakelight-zig, ... }: flakelight-zig ./. {
license = "AGPL-3.0-or-later";
zigDependencies = pkgs: pkgs.callPackage ./deps.nix {};
zigDependencies = pkgs: pkgs.linkFarm "zig-deps" [{
name = "1220bc9ee317a38d7868cbcfe1ab3c15fe3ffe897edb125ad4731584648ad08ed30a";
path = builtins.fetchGit {
url = "https://github.com/accelbread/bread-lib-zig.git";
rev = "0883dc65c35d1c12bfaec19bfcbfb1d58bd7e5a7";
};
}];
};
}
```

If all of your dependencies are git deps, then the above can be extracted from
`build.zig.zon` with Nix code by using `flakelight-zig.lib.parseZon` to read
`build.zig.zon` into a Nix attrset.
2 changes: 1 addition & 1 deletion flakelight-zig.nix
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ warnIf (! builtins ? readFileType) "Unsupported Nix version in use."
meta = defaultMeta;
}));

devShell.packages = pkgs: (with pkgs; [ zig zls pkg-config zon2nix ])
devShell.packages = pkgs: (with pkgs; [ zig zls pkg-config ])
++ config.zigSystemLibs pkgs;

checks.test = pkgs: ''
Expand Down

0 comments on commit 50250df

Please sign in to comment.