-
Notifications
You must be signed in to change notification settings - Fork 24
/
flake.nix
173 lines (148 loc) · 5.49 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
163
164
165
166
167
168
169
170
171
172
173
{
description = "plutip-core";
nixConfig = {
extra-substituters = [ "https://cache.iog.io" ];
extra-trusted-public-keys = [ "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" ];
};
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
haskell-nix = {
url = "github:input-output-hk/haskell.nix";
};
CHaP = {
url = "github:input-output-hk/cardano-haskell-packages?ref=repo";
flake = false;
};
iohk-nix.url = "github:input-output-hk/iohk-nix";
iohk-nix.inputs.nixpkgs.follows = "haskell-nix/nixpkgs";
cardano-node.url = "github:input-output-hk/cardano-node/8.1.1";
flake-parts.url = "github:hercules-ci/flake-parts";
pre-commit-hooks-nix.url = "github:cachix/pre-commit-hooks.nix";
hci-effects.url = "github:hercules-ci/hercules-ci-effects";
# Flake monorepo toolkit
flake-lang.url = "github:mlabs-haskell/flake-lang.nix";
tx-village.url = "github:mlabs-haskell/tx-village/connor/separate-plutip";
};
outputs =
inputs@{ nixpkgs, haskell-nix, CHaP, iohk-nix, cardano-node, flake-parts, ... }:
let
defaultSystems = [ "x86_64-linux" "x86_64-darwin" ];
perSystem = nixpkgs.lib.genAttrs defaultSystems;
haskellModules = system: [
({ pkgs, ... }:
{
packages = {
cardano-crypto-praos.components.library.pkgconfig = pkgs.lib.mkForce [ [ pkgs.libsodium-vrf ] ];
cardano-crypto-class.components.library.pkgconfig = pkgs.lib.mkForce [ [ pkgs.libsodium-vrf pkgs.secp256k1 ] ];
cardano-wallet.components.library.build-tools = [
pkgs.buildPackages.buildPackages.gitMinimal
];
cardano-config.components.library.build-tools = [
pkgs.buildPackages.buildPackages.gitMinimal
];
};
}
)
({ pkgs, ... }:
let
nodeExes = cardano-node.packages.${system};
in
{
packages.plutip-core.components.tests.plutip-tests = {
pkgconfig = [ [ pkgs.makeWrapper ] ];
postInstall = with pkgs; ''
wrapProgram $out/bin/plutip-tests \
--prefix PATH : "${lib.makeBinPath [
nodeExes.cardano-node
nodeExes.cardano-cli
]}"
'';
};
packages.plutip-core.components.exes.local-cluster = {
pkgconfig = [ [ pkgs.makeWrapper ] ];
postInstall = with pkgs; ''
wrapProgram $out/bin/local-cluster \
--prefix PATH : "${lib.makeBinPath [
nodeExes.cardano-node
nodeExes.cardano-cli
]}"
'';
};
})
];
in
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
./pre-commit.nix
./hercules-ci.nix
./plutip-rust/build.nix
];
flake = {
haskellModules = perSystem haskellModules;
};
systems = defaultSystems;
perSystem = { system, config, pkgs, pkgsForHaskellNix, ... }:
let
project =
pkgsForHaskellNix.haskell-nix.cabalProject {
name = "plutip-core";
src = ./.;
inputMap = {
"https://input-output-hk.github.io/cardano-haskell-packages" = CHaP;
};
compiler-nix-name = "ghc8107";
shell = {
withHoogle = true;
exactDeps = true;
tools = {
# haskell-language-server = { }; # FIXME(bladyjoker): Can't use this really until we upgrade GHC
cabal = { };
ghcid = { };
};
nativeBuildInputs = with pkgsForHaskellNix; [
entr
git
fd
# Cardano tools
cardano-node.packages.${system}.cardano-cli
cardano-node.packages.${system}.cardano-node
];
};
modules = haskellModules system;
};
flake = project.flake { };
in
{
_module.args = {
pkgs = import nixpkgs {
inherit system;
};
pkgsForHaskellNix = import inputs.haskell-nix.inputs.nixpkgs {
overlays = [ iohk-nix.overlays.crypto haskell-nix.overlay ];
inherit (haskell-nix) config;
inherit system;
};
};
packages = flake.packages
// {
default = config.packages."plutip-core:lib:plutip-core";
};
inherit (flake) apps;
checks = flake.checks // {
"plutip-core:test:plutip-tests" = flake.checks."plutip-core:test:plutip-tests".overrideAttrs {
# Override the derivation name otherwise the socket paths for cardano nodes (which contain the derivation name)
# in the nix sandbox will be too long for `x86_64-darwin`
name = "plutip-tests";
};
};
devShells = {
# Adds pre-commit packages and shell hook to the haskell shell
default = pkgs.mkShell {
inputsFrom = [ config.devShells.haskell config.devShells.dev-pre-commit ];
shellHook = config.devShells.haskell.shellHook + config.devShells.dev-pre-commit.shellHook;
};
haskell = flake.devShell;
};
};
};
}