Automate Haskell development with nixpkgs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

profile.nix 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. ################################################################################
  2. #
  3. # This file is part of the package nix-hs. It is subject to the license
  4. # terms in the LICENSE file found in the top-level directory of this
  5. # distribution and at:
  6. #
  7. # https://code.devalot.com/open/nix-hs
  8. #
  9. # No part of this package, including this file, may be copied, modified,
  10. # propagated, or distributed except according to the terms contained in
  11. # the LICENSE file.
  12. #
  13. # Helper file for post-processing Haskell profiles.
  14. { pkgs ? import <nixpkgs> { }
  15. , compiler ? "default" # Which version of GHC to use, or "default".
  16. }:
  17. let
  18. # Select a compiler:
  19. basePackages =
  20. if compiler == "default"
  21. then pkgs.haskellPackages
  22. else pkgs.haskell.packages."ghc${compiler}";
  23. in pkgs.mkShell {
  24. buildInputs = [
  25. basePackages.ghc # For hp2ps
  26. basePackages.ghc-prof-aeson-flamegraph
  27. pkgs.ghostscript # For ps2pdf
  28. pkgs.flamegraph # For flamegraph.pl
  29. ];
  30. shellHook = ''
  31. process_haskell_hp_file() {
  32. dir=$(dirname "$1")
  33. base=$(basename "$1" ".hp")
  34. (
  35. set -e
  36. cd $dir
  37. hp2ps -e11in -M -c "$base".hp
  38. ps2pdf "$base".ps
  39. rm -f "$base".ps "$base".aux
  40. )
  41. }
  42. '';
  43. }