2022-08-22 15:56:44 -07:00
|
|
|
# Nix Flake for Zig
|
|
|
|
|
|
|
|
This repository is a Nix flake packaging the [Zig](https://ziglang.com)
|
|
|
|
compiler. The flake mirrors the binaries built officially by Zig and
|
|
|
|
does not build them from source.
|
|
|
|
|
2022-08-22 19:10:14 -07:00
|
|
|
This repository is meant to be consumed primarily as a flake but the
|
|
|
|
`default.nix` can also be imported directly by non-flakes, too.
|
2022-08-22 15:56:44 -07:00
|
|
|
|
2022-08-22 19:10:14 -07:00
|
|
|
The flake outputs are documented in `flake.nix` but an overview:
|
|
|
|
|
|
|
|
* Default package and "app" is the latest released version
|
|
|
|
* `packages.<version>` for a tagged release
|
2022-08-22 19:31:09 -07:00
|
|
|
* `packages.master` for the latest nightly release
|
|
|
|
* `packages.master-<date>` for a nightly release
|
|
|
|
* `overlay` is an overlay that adds `zigpkgs` to be the packages
|
|
|
|
exposed by this flake
|
2022-08-23 09:44:15 -07:00
|
|
|
* `template.compiler-dev` to setup a development environment for Zig
|
|
|
|
compiler development.
|
2022-08-22 15:56:44 -07:00
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
2022-08-23 09:44:15 -07:00
|
|
|
### Flake
|
2022-08-22 15:56:44 -07:00
|
|
|
|
|
|
|
In your `flake.nix` file:
|
|
|
|
|
|
|
|
```nix
|
|
|
|
{
|
|
|
|
inputs.zig.url = "github:mitchellh/zig-overlay";
|
2022-08-22 19:10:14 -07:00
|
|
|
|
2022-08-22 15:56:44 -07:00
|
|
|
outputs = { self, zig, ... }: {
|
|
|
|
...
|
|
|
|
};
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
In a shell:
|
|
|
|
|
|
|
|
```sh
|
2022-08-22 19:10:14 -07:00
|
|
|
# run the latest released version
|
2022-08-22 15:56:44 -07:00
|
|
|
$ nix run 'github:mitchellh/zig-overlay'
|
2022-08-22 19:31:09 -07:00
|
|
|
# open a shell with nightly version dated 2021-02-13 (oldest version available)
|
|
|
|
$ nix shell 'github:mitchellh/zig-overlay#master-2021-02-13'
|
|
|
|
# open a shell with latest nightly version
|
|
|
|
$ nix shell 'github:mitchellh/zig-overlay#master'
|
2022-08-22 15:56:44 -07:00
|
|
|
```
|
|
|
|
|
2022-08-23 09:44:15 -07:00
|
|
|
### Compiler Development
|
|
|
|
|
|
|
|
This flake outputs a template that makes it easy to work on the Zig
|
|
|
|
compiler itself. If you're looking to contribute to the Zig compiler,
|
|
|
|
here are the easy steps to setup a working development environment:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
# clone zig and go into that directory
|
|
|
|
$ git clone https://github.com/ziglang/zig.git
|
|
|
|
$ cd zig
|
|
|
|
# setup the template
|
|
|
|
$ nix flake init -t 'github.com:mitchellh/zig-overlay#compiler-dev'
|
|
|
|
# Two options:
|
|
|
|
# (1) start a shell, this forces bash
|
|
|
|
$ nix develop
|
|
|
|
# (2) If you have direnv installed, you can start the shell environment
|
|
|
|
# in your active shell (fish, zsh, etc.):
|
|
|
|
$ direnv allow
|
|
|
|
```
|
|
|
|
|
2022-08-22 15:56:44 -07:00
|
|
|
## Thanks
|
|
|
|
|
|
|
|
This repository is originally hosted by the username `arqv`. This user
|
|
|
|
and repository disappeared at some point and I had a local checkout so
|
|
|
|
I've forked it, modified it, and reuploaded it here.
|