blob: 489651e4308100c4c35a72f66ff0bcc5558adc2d (
plain)
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
|
nixpkgs:
{ name # the main module namespace
, nick # a short name, for the executable
, deps # deps get passed to ghc
}:
with nixpkgs;
let
nsToPath = ns: builtins.toString (builtins.replaceStrings ["."] ["/"] ns);
path = nsToPath name;
depsToPackageSet = packageSet: deps:
map (s: builtins.getAttr s packageSet) deps;
claySrc = pkgs.fetchFromGitHub {
owner = "sebastiaanvisser";
repo = "clay";
rev = "cc7729b1b42a79e261091ff7835f7fc2a7ae3cee";
sha256 = "1vd67976lvi5l4qq18zy6j44apynkl44ps04p8vwfx4gzr895dyp";
};
ghc865_ = pkgs.haskell.packages.ghc865.override (oldAttrs: {
overrides = with pkgs.haskell.lib; self: super: {
clay = self.callCabal2nix "clay" claySrc {};
wai-middleware-metrics = dontCheck super.wai-middleware-metrics;
};
});
ghc = ghc865_.ghcWithPackages (hp: depsToPackageSet hp deps);
in stdenv.mkDerivation {
name = name;
version = "0";
src = ../../.; # this is the git root
nativeBuildInputs = [ ghc ];
strictDeps = true;
buildPhase = ''
#
mkdir -p $out/{bin,static} ${path}
#
# compile with ghc
#
${ghc}/bin/ghc -Werror -i. \
--make ${path}.hs \
-main-is ${name} \
-o $out/bin/${nick}
'';
# the install process was handled above
installPhase = "exit 0";
} // { env = ghc; }
|