Building Snix

This document describes how to build the project locally, both for interactive development as well as referring to it from Nix code (for example, to run one of its binaries on your machine).

Please check the Contribution Guide on how to contribute after following this guide.

Requirements

Getting the sources

Snix is hosted in its own Forgejo instance, hosted on git.snix.devexternal link .

Check out the source code as follows:

git clone https://git.snix.dev/snix/snix.git

Interactive development

direnv allow

This provides all the necessary tools and dependencies to interactively build the source code, using cargo build etc.

Building only

It is also possible to build the different Snix crates with Nix, in which you don’t need to enter the shell. From the root of the repository, you can build as follows:

$ nix-build -A snix.cli.default-cli

Alternatively, you can use the mgexternal link wrapper from anywhere in the repository (requires the direnv setup from above):

mg build //snix/cli:default-cli

This uses crate2nixexternal link to build each crate dependency individually.

Binary cache for Development

If you want to fetch store paths built by CI, you can configure our CI binary cache as a Nix substituter:

{
  nix.settings.trusted-public-keys = [
    "cache.snix.dev-1:miTqzIzmCbX/DyK2tLNXDROk77CbbvcRdWA4y2F8pno="
  ];
  nix.settings.substituters = [
    "https://cache.snix.dev"
  ];
}

The cache is provided by snix-store daemon and nar-bridge. We also expose the snix-[ca]store gRPC interfaces on the same domain (read-only, no listing).

Keep in mind there’s no guarantees on paths being available, they might get GC’ed eventually.

Further reading

Checkout the Component Overview to learn more about the project structure.