forked from mlabs-haskell/plutip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
162 lines (139 loc) · 5.26 KB
/
flake.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
{
description = "plutip";
inputs = {
haskell-nix.follows = "bot-plutus-interface/haskell-nix";
nixpkgs.follows = "bot-plutus-interface/haskell-nix/nixpkgs";
iohk-nix.follows = "bot-plutus-interface/iohk-nix";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
bot-plutus-interface.url =
"github:mlabs-haskell/bot-plutus-interface";
};
outputs =
{ self, bot-plutus-interface, nixpkgs, haskell-nix, iohk-nix, ... }@inputs:
let
defaultSystems = [ "x86_64-linux" "x86_64-darwin" ];
perSystem = nixpkgs.lib.genAttrs defaultSystems;
nixpkgsFor = system:
import nixpkgs {
overlays =
[ haskell-nix.overlay (import "${iohk-nix}/overlays/crypto") ];
inherit (haskell-nix) config;
inherit system;
};
nixpkgsFor' = system: import nixpkgs { inherit system; };
extraSources = inputs.bot-plutus-interface.extraSources ++ [{
src = inputs.bot-plutus-interface;
subdirs = [ "." ];
}];
haskellModules = bot-plutus-interface.haskellModules ++ [
({ config, pkgs, ... }: {
packages.plutip.components.tests."plutip-tests".build-tools = [
config.hsPkgs.cardano-cli.components.exes.cardano-cli
config.hsPkgs.cardano-node.components.exes.cardano-node
];
packages.plutip.components.exes.plutip-server = {
pkgconfig = [ [ pkgs.makeWrapper ] ];
postInstall = with pkgs; ''
wrapProgram $out/bin/plutip-server \
--prefix PATH : "${lib.makeBinPath [
config.hsPkgs.cardano-cli.components.exes.cardano-cli
config.hsPkgs.cardano-node.components.exes.cardano-node
]}"
'';
};
packages.plutip.components.exes.local-cluster = {
pkgconfig = [ [ pkgs.makeWrapper ] ];
postInstall = with pkgs; ''
wrapProgram $out/bin/local-cluster \
--prefix PATH : "${lib.makeBinPath [
config.hsPkgs.cardano-cli.components.exes.cardano-cli
config.hsPkgs.cardano-node.components.exes.cardano-node
]}"
'';
};
})
];
projectFor = system:
let
pkgs = nixpkgsFor system;
pkgs' = nixpkgsFor' system;
project = pkgs.haskell-nix.cabalProject {
name = "plutip";
src = ./.;
compiler-nix-name = "ghc8107";
shell = {
withHoogle = true;
exactDeps = true;
additional = ps: [ ps.bot-plutus-interface ];
tools.haskell-language-server = "latest";
nativeBuildInputs = with pkgs'; [
# Haskell Tools
haskellPackages.fourmolu
haskellPackages.cabal-install
haskellPackages.cabal-fmt
nixpkgs-fmt
hlint
entr
ghcid
git
fd
# hls doesn't support preprocessors yet so this has to exist in PATH
haskellPackages.record-dot-preprocessor
# Cardano tools
project.hsPkgs.cardano-cli.components.exes.cardano-cli
project.hsPkgs.cardano-node.components.exes.cardano-node
];
};
inherit (bot-plutus-interface) cabalProjectLocal;
inherit extraSources;
modules = haskellModules;
};
in
project;
in
{
inherit extraSources haskellModules;
inherit (bot-plutus-interface) cabalProjectLocal;
project = perSystem projectFor;
flake = perSystem (system: (projectFor system).flake { });
defaultPackage = perSystem (system:
let lib = "plutip:lib:plutip";
in self.flake.${system}.packages.${lib});
packages = perSystem (system: self.flake.${system}.packages);
apps = perSystem (system: self.flake.${system}.apps);
devShell = perSystem (system: self.flake.${system}.devShell);
# This will build all of the project's executables and the tests
check = perSystem
(system:
(nixpkgsFor system).runCommand "combined-check"
{
nativeBuildInputs = builtins.attrValues self.checks.${system}
++ builtins.attrValues self.flake.${system}.packages;
} ''mkdir $out''
);
checks = perSystem (system:
self.flake.${system}.checks // {
formatting = (nixpkgsFor system).runCommand "formatting-check"
{
nativeBuildInputs = [
self.devShell.${system}.inputDerivation
self.devShell.${system}.nativeBuildInputs
];
}
''
cd ${self}
export LC_CTYPE=C.UTF-8
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
export IN_NIX_SHELL='pure'
make format_check cabalfmt_check nixpkgsfmt_check lint
mkdir $out
'';
});
# Instruction for the Hercules CI to build on x86_64-linux only, to avoid errors about systems without agents.
herculesCI.ciSystems = [ "x86_64-linux" ];
};
}