How do Nix builds work?
jvns.ca
jvns.ca
I can definitely empathise with the debugging approach - with Nix you kind of have to take a scattergun approach, search around randomly trying to find packages or solutions. I’ve since given up using search.nixos.org and now just grep the nixpkgs repository. Often the solution will be in a commented out piece of code saying “removed ugly hack”, then I learn from their solution and apply the ugly hack anyway. Because, you know.
I still use search.nixos.org as well, but this is the single biggest step anyone can take to massively level up with Nix. Nixpkgs is an incredibly valuable collection of examples, both of how to use Nix and of how to configure the upstream services that NixOS supports.
It might sound ugly, or overinvolved, or intimidating, but once you add the Nixpkgs codebase to your list of reference documents, many things become way faster and easier.
With flakes, IIRC, `nix edit nixpkgs#<pkg>` will also open up the source. https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3...
Just because you want to peek at a package's build's source does not mean you have to go grepping blind through the repo. Better to be pointed directly to the right file by one of these tools!
I use the source link on the NixOS Package Search site on mobile all the time, when I want to refer myself or others to examples but I'm afk.
Same experience with mkDerivation as well - I personally have lots of hope for https://github.com/DavHau/drv-parts and similar projects to improve that situation :)
I think in the case of Nix it is especially important to have a good grasp of the fundamentals so that you can verify your (possibly wrong) assumptions when troubleshooting a build failure, evaluation failure or when using the higher level constructs of nixpkgs.
There is a large overlap of users who like using the Nix package manager, & of those who like using NixOS. -- I don't think any official documentation refers to 'NixOS' as 'Nix'. Maybe in some discussions, people are imprecise.
I think a sample sentence like "I love Nix! I use NixOS as my daily driver" doesn't really conflate the two too much.