-
Notifications
You must be signed in to change notification settings - Fork 38
/
shell.nix
67 lines (56 loc) · 1.91 KB
/
shell.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
let
default_nixpkgs = (import <nixpkgs> {}).fetchFromGitHub {
owner = "NixOS";
repo = "nixpkgs";
rev = "68cc97d306d3187c142cfb2378852f28d47bc098";
sha256 = "07zxbk4g4d51hf7dhsj6h7jy5c2iccm2lwaashj36inkhh9lrqa3";
};
in
{ nixpkgs ? default_nixpkgs }:
let
orig_pkgs = import nixpkgs {};
llvm-hs-repo = orig_pkgs.fetchFromGitHub {
owner = "llvm-hs";
repo = "llvm-hs";
rev = "76cd4d5107862401a7ebbe1bb9cc1cf172fa1d66";
sha256 = "0bnh0yyjflhvc8vjrqsa25k7issnvkvgx149bnq7avka5mx2m99m";
};
hsOverlay = self: super: {
haskellPackages = super.haskellPackages.override {
overrides = self': super': {
llvm-hs-pure = super'.callPackage (import "${llvm-hs-repo}/llvm-hs-pure") {};
llvm-hs = super'.callPackage (import "${llvm-hs-repo}/llvm-hs") {
llvm-config = self.llvm_4;
};
llvm-hs-pretty = super'.callPackage ./. {};
};
};
};
pkgs = import orig_pkgs.path { overlays = [ hsOverlay ]; };
env =
let
# Determine if a package is a Haskell package or not. Stolen from:
# <nixpkgs/pkgs/development/haskell-modules/generic-builder.nix>
isHaskellPkg = x: (x ? pname) && (x ? version) && (x ? env);
isSystemPkg = x: !isHaskellPkg x;
allDependencies =
let inherit (pkgs.haskellPackages) llvm-hs-pretty; in
builtins.concatLists [
llvm-hs-pretty.nativeBuildInputs
llvm-hs-pretty.propagatedNativeBuildInputs
]
;
haskellDependencies = builtins.filter isHaskellPkg allDependencies;
systemDependencies = builtins.filter isSystemPkg allDependencies;
ghc = pkgs.haskellPackages.ghcWithPackages
(ps: with ps; [ cabal-install ] ++ haskellDependencies)
;
in
pkgs.stdenv.mkDerivation {
name = "llvm-hs-env";
buildInputs = [ ghc ] ++ systemDependencies;
shellHook = "eval $(egrep ^export ${ghc}/bin/ghc)";
}
;
in
env