[Nix-dev] A Journey into our brand-new Haskell infrastructure: Part II
Peter Simons
simons at cryp.to
Tue Jan 13 12:50:28 CET 2015
Hi Thomas,
> How can I override a package to enable profiling?
commit [1] adds helper functions that allow referring to any package "foo"
as "enableLibraryProfiling foo" to get a variant that supports profiling.
If you want to enable profiling for *all* packages, then you can replace
the 'mkDerivation' function with one that enables the feature by default,
i.e. by adding the snippet
| haskellPackageOverrides = self: super: {
| mkDerivation = expr: super.mkDerivation (expr // { enableLibraryProfiling = true; });
| };
to your ~/.nixpkgs/config.nix file.
> Is there an obvious way in general to apply the same override to a
> package and all its dependencies?
No, we can't do that yet. But we can do something else, that's almost
equally goos: we can modify the package set in which a package (and all
its dependencies) are evaluated. Just add
| {
| packageOverrides = super: let self = super.pkgs; in
| {
| foo = self.haskellngPackages.foo.overrideScope (self: super: {
| mkDerivation = expr: super.mkDerivation (expr // { enableLibraryProfiling = true; });
| });
| }
| }
to your ~/.nixpkgs/config.nix to get a variant of "foo" that has profiling
enabled in all its dependencies as well. If you take that stuff to the
extreme, then it looks like [2].
I hope this helps,
Peter
[1] https://github.com/NixOS/nixpkgs/commit/e4a68f0b98c28319913a4f2104ddb0524262f390
[2] https://github.com/NixOS/nixpkgs/blob/9e114ccd2693daab6bca3c05674c549884097925/pkgs/development/haskell-modules/configuration-ghc-7.8.x.nix#L43-87
More information about the nix-dev
mailing list