[Nix-dev] Haskellng - enable profiling
Andreas Herrmann
andreash87 at gmx.ch
Mon Mar 9 23:51:18 CET 2015
I just had the same problem. I have no idea whether it's the right way to do it, but I got it working in the following way:
Assuming that your package description is in `default.nix` (as created by cabal2nix) add the following two files to the same directory:
mypackage.nix:
| { profiling ? false }:
|
| with (import <nixpkgs> {}).pkgs;
|
| let
| mypackage = haskellngPackages.callPackage ./. {};
| in
|
| if profiling
| then mypackage.overrideScope (self: super: {
| inherit stdenv; # Why this line is required is beyond me. =/
| mkDerivation = drv: super.mkDerivation (drv // { enableLibraryProfiling = true; });
| })
| else mypackage
shell.nix:
| { profiling ? false }:
|
| with (import <nixpkgs> {}).pkgs;
| with (import <nixpkgs/pkgs/development/haskell-modules/lib.nix> { inherit pkgs; });
|
| (overrideCabal (import ./mypackage.nix { inherit profiling; }) (drv: {
| buildTools = with haskellngPackages; [ cabal-install ghc-mod yesod-bin ];
| })).env
Now you can build your package with
nix-build --arg profiling true mypackage.nix
And you can open a nix-shell with
nix-shell --arg profiling true
I hope this helps.
Best, Andreas
On Monday 02 March 2015 00:25:26 Carlo Nucera wrote:
> Hi all, I'd like some help to build a haskell package I'm developing
> while transitively enabling profiling. I'm trying to do the thing
> described in
> http://lists.science.uu.nl/pipermail/nix-dev/2015-January/015620.html
> What I'd like here is a demonstration on how to do that directly in
> the definition on myPackage (see below).
>
> Here is, more or less, my .nixpkgs/config.nix:
>
> | { pkgs }: {
> | allowBroken = true;
> | allowUnfree = true;
> |
> | haskellPackageOverrides = self: super: {
> | ghci-ng = self.callPackage /path/to/ghci-ng/default.nix {};
> | myPackage = self.callPackage /path/to/myPackage/default.nix {};
> | };
> |
> | packageOverrides = pkgs: with pkgs; rec {
> |
> | haskellEnv = haskellngPackages.ghcWithPackages cabalPackages;
> |
> | cabalPackages = hp: with hp; [
> | cabal2nix
> | cabal-install-bundle
> | # Other libraries
> |
> | myPackage
> | ];
> | };
> | }
>
> The goal here is to build myPackage with profiling enabled
> (transitively for his dependencies). If you have other advises on this
> file, feel free to share.
>
> Thanks
> Carlo
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
More information about the nix-dev
mailing list