5 ms·
This was very informative. I’ve been using Nix far longer than Julia and I have endured many battles with mkDerivation, never thinking to go one step deeper. I
by i-use-nixos-btw 4y ago
This was very informative. I’ve been using Nix far longer than Julia and I have endured many battles with mkDerivation, never thinking to go one step deeper. I knew that it was a wrapper over a builtin derivation, but I never realised just how simple builtin derivations are to write, and how much fluff they remove from the process.
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.
- pxc 4y ago> I’ve since given up using search.nixos.org and now just grep the nixpkgs repository. 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.
- rgoulter 4y agoIn case anyone overlooks it, search.nixos.org also will link to the nix code in nixpkgs for a package. With flakes, IIRC, `nix edit nixpkgs#<pkg>` will also open up the source. https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-edit.html https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3...
- pxc 4y agoGreat point! If you know what package you want to examine, these are both super handy. 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.
- tomberek 4y agoIt would be helpful to teach people without so much being done by mkDerivation or other builders. While they provide value, they sometimes block learning. I like start with super simple example, if possible.
- phaer 4y agoGrepping nixpkgs is what i do as well, but for functions specifically i found https://noogle.dev/ https://noogle.dev/ to be useful. Same experience with mkDerivation as well - I personally have lots of hope for https://github.com/DavHau/drv-parts https://github.com/DavHau/drv-parts and similar projects to improve that situation :)