override-utils
Ergonomic interface for overriding Nixpkgs
A Nix library that makes it much simpler to customize how packages are built, replacing deeply nested boilerplate with named operations like set, add, append, and modify.
Nix is a package manager that uses a special configuration language to describe software builds. One of its core features is the ability to customize how packages are built by writing "overrides," which are instructions that change specific settings for a package without rewriting its entire definition. In practice, writing these overrides the standard Nix way requires a lot of repetitive, nested code that is easy to get wrong.
This project, override-utils, provides a simpler way to write those customizations. Instead of writing deeply nested attribute merges by hand, you use a small set of named operations like set, add, append, prefix, and modify to describe what should change. The library figures out the rest, including how to merge nested values safely without accidentally erasing unrelated settings.
For example, if you want to add a patch to one package in the Nixpkgs collection, the standard approach requires several layers of nested expressions. With override-utils, the same change takes a single line using the append operation on the patches attribute. The library also handles cases where an attribute might not exist yet, applying a sensible default instead of throwing an error.
The project works with both the newer Nix flakes system and the older non-flake setup. It is written entirely in Nix with no external dependencies. The README includes a detailed tutorial covering all supported operations, including how to target specific items in a list, how to transform every key in a set at once, and how all features can be combined for complex customizations. The author also links to a blog post with additional context about why Nixpkgs overrides are difficult to work with in the first place.
Where it fits
- Add a patch to a Nixpkgs package in a single line instead of writing nested override expressions.
- Safely merge nested attribute values when customizing package builds without erasing unrelated settings.
- Apply the same transformation to every key in a Nix attribute set at once for bulk package customization.
- Combine multiple override operations for complex package customizations while keeping the code readable.