Cameron Yule
Contributing to Nix
I recently made my first contribution to Nixpkgs, the package collection for NixOS, and wanted to document a few notes and learnings from that process. Nix is an ecosystem of tools which together enable reproducible, declarative and reliable systems. It’s comprised of a package manager (Nix), a packages collection (Nixpkgs), a functional language (Nix expressions), and a Linux distribution built using those tools (NixOS).
Nix first caught my attention while I was researching the concept of reproducible builds, which enables verification that binaries were created from a specific version of their source. While reproducible builds offer many benefits, they’re also becoming increasingly important in securing the software supply chain. Nix on its own does not guarantee bit-for-bit reproducibility, but offers the tools to achieve it and reports on the reproducibility of NixOS, which is typically above 99%.
My first contribution was a version update for the mlx Python package. mlx is an open-source array framework from Apple which, when used with Apple’s mlx-lm, allows large language models to run efficiently by leveraging the unified memory architecture of Apple Silicon. I’d tried to install mlx from Nixpkgs, but encountered a build failure for which there was an open bug report.
At a high-level, the process was:
- Read the Nix expression language tutorial.
- Read the Nixpkgs contributors guide.
- Read the Nixpkgs Python documentation.
- Checked out the Nixpkgs repository.
- Verified the build failures were still occurring.
- Fixed the build failures. This was mostly updating patches and dependencies, with some refactoring to match current style.
- Followed the testing guide. I ensured the mlx tests were being run and passing as part of the check phase. I also added passthru tests which exercise the mlx example scripts.
- Verified the build now succeeded.
- Verified packages which depended on the mlx package also succeeded, using nixpkgs-review.
- Opened a pull request for review.
- Addressed the review feedback, and the change was shipped.
Nix has a reputation – sometimes deserved – for it’s difficulty curve, but I found the process of contributing to be both welcoming and well documented.
Tags: til, nix, open-source