[Nix-dev] Use Function Application To Escape Override Hell

Mathnerd314 mathnerd314.gph at gmail.com
Fri Oct 16 04:35:16 CEST 2015


On Thu, Oct 15, 2015 at 3:58 AM, Peter Simons <simons at cryp.to> wrote:

> But how many people understand "callPackage"?

Interesting question. The commit logs suggest between 10-20 people could
write it themselves.
Arguably everyone who has read
http://lethalman.blogspot.com/2014/09/nix-pill-13-callpackage-design-pattern.html
understands callPackage, so that would put it in the 50-150 range based on
some pageview stats I found.
These numbers should be compared to the total number of NixOS users; the
NixOS subreddit has 624 users, so maybe 10-25% understand callPackage, 1-3%
could write it.

And more importantly: why
> should our users even care about it?
>
They at least need to know that callPackage provides a .override method, as
this is (or should be) the preferred way to build unusual variants of
packages, like curl with HTTPS support disabled.

So maybe callPackage should be documented in the manual, in preference to
makeOverridable.

 > The only way to use them from a configuration.nix or config.nix is to
>  > write out with import
> <nixpkgs>/pkgs/development/haskell-modules/lib.nix;
>
> pkgs.haskell.lib works too.
>

Wonderful. This should be documented in the Nixpkgs manual, say under
http://nixos.org/nixpkgs/manual/#how-to-build-with-profiling-enabled

How exactly would one go from that JSON
> file to, say, an Idris binary built with GHC 7.8.4 and shared libraries
> disabled?
>
I already linked to the KDE packages, which go from JSON to (for example)
Dolphin binaries built with Qt 5 and parallel building enabled.
I will repeat the relevant files:
https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/kde-apps-15.04/packages.json
https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/kde-apps-15.04/default.nix
https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/autonix/default.nix

In particular the fold on json in kde-apps/default.nix and the resolveDeps
function in autonix are relevant.

>
> Well, defining a good method to resolve package names to package
> versions and build variants is exactly what this thread is about! Would
> you care to elaborate how exactly that would work for Haskell packages
> in your proposal?
>

I'm not sure how to elaborate beyond saying "Do it like the KDE stuff". I
could do a pull request, if that counts.

-- Mathnerd314
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.science.uu.nl/pipermail/nix-dev/attachments/20151015/00269861/attachment-0001.html 


More information about the nix-dev mailing list