Is there any best practice recommendation for wrapping Nix packages which allows easy overriding of attributes like version and hash (for example for purpose of building package in different version) ?
default.nix is calling callPackage ./unwrapped.nix which builds unwrapped package which is then wrapped in postBuild step.
This approach looks quite elegant, but if I want to override version using
The -unwrapped variant should also be exposed at the arg/nixpkgs level, instead of through a let definition. In general I think let definitions are a bit of an antipattern for packages, they don’t override well.
See e.g. firefox-unwrapped - you probably never want to use the package that way, but it allows overriding it. To be fair, I think most packages used this way should not actually show up in search results - firefox is a bit of an exception.
Alternatively, use the fancy new function arg to mkDerivation, which will allow users to use the values you actually passed in: Nixpkgs 22.05 manual
Still a bit awkward for buildInputs & co, because you somehow need to find the correct one to override, but at least it’s possible.
I tried to search in nixpkgs/pkgs/top-level/all-packages.nix file for unwrapped string and found that there are really very many different ways how people wrap packages.
I looked on Firefox package, but it is too complex for using it as some kind of template approach. Is there any other (more simple) package which you would recommend to use as a good example ?