Skip to content

Building NativeLink with Nix

These instructions contain information on how to work with NativeLink for Nix users.

You’ll need a recent version of Nix with flakes enabled, for instance installed via the next-gen nix installer.

This build doesn’t require cloning the repository, but you need to provide a configuration file, for instance the one at https://github.com/TraceMachina/nativelink/blob/main/nativelink-config/examples/basic_cas.json.

The following command builds and runs NativeLink in release (optimized) mode:

Terminal window
nix run github:TraceMachina/nativelink ./basic_cas.json

You can build a specific PR or branch like so:

Terminal window
nix run github:TraceMachina/nativelink?ref=pull/<PR_NUMBER>/head

Working with container images

View the flake outputs to list available images:

Terminal window
nix flake show

The main nativelink container image is the image output. Other images follow the pattern nativelink-worker-*.

Images use nix2container as builder and get tagged with nix derivation hashes.

To build an image locally and make it available to your container runtime:

Terminal window
nix run github:TraceMachina/nativelink#image.copyToDockerDaemon

To view the tag of an image

Terminal window
nix eval github:TraceMachina/nativelink#image.imageTag --raw

On NixOS

If you’re on NixOS, add the following to your system configuration:

programs.nix-ld.enable = true;
services.envfs.enable = true;