Guest User

Untitled

a guest
May 20th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. COMPILER='ghc822'
  4. HASKVER='_8_2'
  5. NIXPKGS='import <darwin> {}'
  6. HASKPKGS="haskellPackages${HASKVER}"
  7. PKGNAME=$(basename "$PWD")
  8.  
  9. START="$PWD"
  10. while [[ "$PWD" != "/" && ! -f default.nix ]]; do
  11. cd ..
  12. done
  13.  
  14. if [[ "$PWD" = "/" ]]; then
  15. cd "$START"
  16. while [[ "$PWD" != "/" && ! -d .git && ! -f .git ]]; do
  17. cd ..
  18. done
  19. fi
  20.  
  21. if [[ "$PWD" = "/" ]]; then
  22. echo "Error: Could not find default.nix or .git"
  23. exit 1
  24. fi
  25.  
  26. read -r -d '' INPUT <<- EOM
  27. let nixpkgs = ${NIXPKGS};
  28. pkgs = nixpkgs.pkgs;
  29.  
  30. haveDefault = builtins.pathExists ./default.nix;
  31.  
  32. package =
  33. if haveDefault
  34. then import ./default.nix {
  35. compiler = "${COMPILER}";
  36. nixpkgs = pkgs.lib.recursiveUpdate nixpkgs
  37. { pkgs.lib.inNixShell = false; };
  38. }
  39. else pkgs.${HASKPKGS}.callCabal2nix "${PKGNAME}" ./. {};
  40.  
  41. compiler =
  42. if haveDefault
  43. then pkgs.${HASKPKGS}.ghc
  44. else package.compiler;
  45.  
  46. packages =
  47. if haveDefault
  48. then package.buildInputs
  49. else pkgs.haskell.lib.getHaskellBuildInputs package;
  50.  
  51. cabalInstallVersion = {
  52. ghc802 = "1.24.0.2";
  53. ghc822 = "2.0.0.1";
  54. ghc842 = "2.2.0.0";
  55. };
  56.  
  57. hoogleExpr = <nixpkgs/pkgs/development/haskell-modules/hoogle.nix>;
  58.  
  59. haskell-ide-engine = import (pkgs.fetchFromGitHub {
  60. owner = "domenkozar";
  61. repo = "hie-nix";
  62. rev = "dbb89939da8997cc6d863705387ce7783d8b6958";
  63. sha256 = "1bcw59zwf788wg686p3qmcq03fr7bvgbcaa83vq8gvg231bgid4m";
  64. # date = 2018-03-27T10:14:16+01:00;
  65. }) {};
  66.  
  67. hie = {
  68. ghc802 = haskell-ide-engine.hie80;
  69. ghc822 = haskell-ide-engine.hie82;
  70. ghc842 = throw "HIE not supported on GHC 8.4.2 yet";
  71. };
  72.  
  73. ghcEnv = compiler.withPackages
  74. (p: with p;
  75. let hoogle = callPackage hoogleExpr { inherit packages; }; in
  76. [ hpack criterion hdevtools hoogle hie.${COMPILER}
  77. (callHackage "cabal-install" cabalInstallVersion.${COMPILER} {})
  78. ] ++ packages);
  79.  
  80. in ghcEnv
  81. EOM
  82.  
  83. exec nix-shell -p "$INPUT" "$@"
Add Comment
Please, Sign In to add comment