TB: Build a nix pkgs out of nixpkgs
Sean Borg June 08, 2026 [Tiny Blog] #NixNixpkgs uses CallPackage to simplify things in Nixpkgs
Often I find myself making things to eventually go into my nix config so taking advantage of CallPackage is helpful, but it can be quite tedious to build my whole config repeatedly to confirm I got all the nix right...
Here is where this short snippet comes in handy
nix-build -E 'with import <nixpkgs> { }; callPackage ./path/to/default.nix { }'
This builds like nixpkgs does allowing me to test everything without needing to jump to my config and build the whole machine every time.
Links to learn CallPackage itself
Think I originally learned (and have now forgot) how callpackage works from https://github.com/NixOS/nixos-summer/blob/main/content/blog/callpackage-a-tool-for-the-lazy.md this has now been used as a base to write https://nix.dev/tutorials/callpackage which I shall have to read at some point.
Attempting to find the original article I read I came across a few links, I have barely skim read but hopefully will have some time to one day
- https://toraritte.github.io/posts/callPackage/2024-08-18-callPackage.html
- https://github.com/NixOS/nix.dev/issues/651
- https://github.com/NixOS/nixpkgs/issues/36354
stackoverflowWhere iscallPackagedefined in the Nixpkgs repo (or how to find Nix lambda definitions in general)?nixos discourseWhere iscallPackagedefined exactly? (part 2)- Tangential:
- https://github.com/NixOS/nixpkgs/pull/270696