It is no surprise that such a package definition is a bit overwhelming to anyone. When you understand what the effect of various attributes, your example package becomes quite straight-forward.
In my experience, you arrive at such a package definition as follows. I'll assume you're not packaging something from a language-specific repository for now. Something you might build with make
, for example.
- Start with mkDerivation
- Watch the build fail
- Fix an error, by adding dependencies, extra commands, configure flags, patches, etc.
- Repeat
So there you have it, it's trial and error. Experience with the required build tools helps a lot.
Some hints:
- Look at similar packages, how they are defined
- Read the Nixpkgs documentation
- Scan through the support code for language ecosystem packages
- https://nixos.wiki/wiki/Generic_Algorithm_on_Doing_Packaging