by i-use-nixos-btw · 3y ago · 0 comments
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.
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 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.