Decentralize Your Nix Builds with a P2P Git Cache
If you've ever worked with Nix, you know the pain of waiting for dependencies to download. Even with the official binary cache, sometimes you're stuck fetching from source or waiting on a central server. What if you could share those builds directly with your team or community, cutting down on redundant downloads and speeding up everyone's workflow?
Enter Gachix. It's a peer-to-peer Git caching layer designed to decentralize Nix builds. Instead of relying solely on a central binary cache, Gachix lets your local Nix store become a shareable cache for others, and lets you pull from their caches too. It turns every developer's machine into a potential node in a distributed caching network.
What It Does
Gachix is a tool that wraps around Git to create a distributed, peer-to-peer cache for Nix build artifacts. In simple terms, it lets you push your locally built Nix packages to a Git remote (like a branch), and allows others to pull from that remote as a substituter. It effectively turns a Git repository into a simple, decentralized Nix binary cache.
Why It's Cool
The clever part is in its simplicity. It doesn't require setting up a dedicated Nix binary cache server (like nix-serve or a Cachix instance). It piggybacks on a version control system you're already using. This makes it incredibly easy to share builds within a private team—just use a private Git repo. It's also great for open-source projects or workshops where you want participants to share builds without infrastructure overhead.
It's not trying to replace services like Cachix for large-scale, high-performance caching. Instead, it solves a different problem: lightweight, ad-hoc, peer-to-peer sharing. Think of it as the "local network share" for Nix builds, but over the internet using Git as the transport.
How to Try It
Getting started is straightforward. You'll need git, nix, and bash installed.
First, clone the repository:
git clone https://github.com/EphraimSiegfried/gachix
cd gachix
The main script is gachix.sh. You can use it to push your local store paths to a Git branch. The repository README provides the core examples. At its heart, you configure a Git remote as your cache target and then use the script to push and pull store paths.
It's an early-stage project, so diving into the source is the best way to understand its current capabilities and try it out. Check the GitHub repository for the latest details and instructions.
Final Thoughts
Gachix is a neat, pragmatic hack that fits the Nix philosophy of reproducibility and decentralization. It's most useful in smaller, collaborative environments where setting up a full binary cache is overkill. For example, if you're pair programming with a colleague and you've both built the same massive dependency, this could save the second person a long build time instantly.
It's a reminder that sometimes the most effective tools are the ones that creatively reuse existing systems. If you're deep in the Nix ecosystem and often find yourself wishing for easier build sharing, Gachix is definitely worth a look.
@githubprojects
Repository: https://github.com/EphraimSiegfried/gachix