forked from tqtezos/stablecoin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
104 lines (95 loc) · 3.3 KB
/
default.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# SPDX-FileCopyrightText: 2020 TQ Tezos
# SPDX-License-Identifier: MIT
{ sources ? import ./nix/sources.nix
, static ? true
, haskell-nix ? import sources."haskell.nix" {
sourcesOverride = { hackage = sources."hackage.nix"; stackage = sources."stackage.nix"; };
}
, pkgs ? import sources.nixpkgs haskell-nix.nixpkgsArgs
, weeder-hacks ? import sources.haskell-nix-weeder { inherit pkgs; }
, ligo ? (import "${sources.ligo}/nix" { }).ligo-bin
, morley ? (import "${sources.morley}/ci.nix").packages.morley.exes.morley
}:
let
haskell-nix =
if static
then pkgs.pkgsCross.musl64.haskell-nix
else pkgs.haskell-nix;
local-packages = [{
name = "stablecoin";
subdirectory = ".";
}];
local-packages-names = map (p: p.name) local-packages;
projectSrc = haskell-nix.haskellLib.cleanGit {
name = "stablecoin";
src = ./haskell;
};
# haskell.nix does not support 'include' in package.yaml, we have to generate .cabal ourselves
cabalFile = pkgs.runCommand "stablecoin.cabal" {} ''
${pkgs.haskellPackages.hpack}/bin/hpack ${projectSrc} - > $out
'';
project = haskell-nix.stackProject {
# project src with .cabal file added
src = pkgs.runCommand "src-with-cabal" {} ''
cp -r --no-preserve=mode ${projectSrc} $out
cp ${cabalFile} $out/stablecoin.cabal
'';
ignorePackageYaml = true;
modules = [
{
packages = pkgs.lib.genAttrs local-packages-names (packageName: {
ghcOptions = [
"-ddump-to-file" "-ddump-hi"
"-O0" "-Werror"
];
postInstall = weeder-hacks.collect-dump-hi-files;
# enable haddock for local packages
doHaddock = true;
});
# disable haddock for dependencies
doHaddock = false;
}
];
};
tezos-contract = pkgs.stdenv.mkDerivation {
name = "stablecoin.tz";
src = ./ligo;
nativeBuildInputs = [ ligo ];
buildPhase = "make stablecoin.tz";
installPhase = "cp stablecoin.tz $out";
};
tezos-contract-fa1-2 = pkgs.stdenv.mkDerivation {
name = "stablecoin.tz";
src = ./ligo;
nativeBuildInputs = [ ligo ];
buildPhase = "make stablecoin.fa1.2.tz";
installPhase = "cp stablecoin.fa1.2.tz $out";
};
tezos-metadata-contract = pkgs.stdenv.mkDerivation {
name = "stablecoin.tz";
src = ./ligo;
nativeBuildInputs = [ ligo ];
buildPhase = "make metadata.tz";
installPhase = "cp metadata.tz $out";
};
tezos-client = (import "${sources.tezos-packaging}/nix/build/pkgs.nix" {}).ocamlPackages.tezos-client;
# nixpkgs has weeder 2, but we use weeder 1
weeder-legacy = pkgs.haskellPackages.callHackageDirect {
pkg = "weeder";
ver = "1.0.9";
sha256 = "0gfvhw7n8g2274k74g8gnv1y19alr1yig618capiyaix6i9wnmpa";
} {};
weeder-script = weeder-hacks.weeder-script {
weeder = weeder-legacy;
hs-pkgs = project;
local-packages = local-packages;
};
in
{
lib = project.stablecoin.components.library;
haddock = project.stablecoin.components.library.haddock;
test = project.stablecoin.components.tests.stablecoin-test;
nettest = project.stablecoin.components.tests.stablecoin-nettest;
stablecoin-client = project.stablecoin.components.exes.stablecoin-client;
inherit tezos-contract tezos-contract-fa1-2 tezos-metadata-contract tezos-client pkgs weeder-script morley;
}