forked from mlabs-haskell/ply
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
169 lines (143 loc) · 5.27 KB
/
flake.nix
File metadata and controls
169 lines (143 loc) · 5.27 KB
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
{
description = "Ply example";
inputs = {
nixpkgs.follows = "plutip/nixpkgs";
haskell-nix.follows = "plutip/haskell-nix";
plutip.url = "github:mlabs-haskell/plutip";
plutarch.url = "github:Plutonomicon/plutarch-plutus";
ply.url = "../.";
};
outputs = inputs@{ self, nixpkgs, haskell-nix, plutarch, plutip, ... }:
let
# GENERAL
supportedSystems = with nixpkgs.lib.systems.supported; tier1 ++ tier2 ++ tier3;
perSystem = nixpkgs.lib.genAttrs supportedSystems;
nixpkgsFor = system: import nixpkgs {
inherit system;
overlays = [ haskell-nix.overlay (import "${plutip.inputs.iohk-nix}/overlays/crypto") ];
inherit (haskell-nix) config;
};
nixpkgsFor' = system: import nixpkgs { inherit system; };
deferPluginErrors = true;
# ONCHAIN / Plutarch
onchain = rec {
ghcVersion = "923";
compiler-nix-name = "ghc${ghcVersion}";
projectFor = system:
let
pkgs = import plutarch.inputs.nixpkgs {
inherit system;
inherit (plutarch.inputs.haskell-nix) config;
overlays = [
plutarch.inputs.haskell-nix.overlay
(import "${plutarch.inputs.iohk-nix}/overlays/crypto")
];
};
pkgs' = nixpkgsFor' system;
hls = (plutarch.hlsFor compiler-nix-name system);
myPlutarchHackages = plutarch.inputs.haskell-nix-extra-hackage.mkHackagesFor system compiler-nix-name [
"${inputs.plutarch}"
"${inputs.ply}/ply-core"
"${inputs.ply}/ply-plutarch"
];
in
pkgs.haskell-nix.cabalProject' (plutarch.applyPlutarchDep pkgs {
inherit compiler-nix-name;
src = ./onchain;
index-state = "2022-06-01T00:00:00Z";
inherit (myPlutarchHackages) extra-hackages extra-hackage-tarballs modules;
shell = {
withHoogle = true;
exactDeps = true;
# We use the ones from Nixpkgs, since they are cached reliably.
# Eventually we will probably want to build these with haskell.nix.
nativeBuildInputs = [
pkgs'.cabal-install
pkgs'.fd
pkgs'.haskellPackages.apply-refact
pkgs'.haskellPackages.cabal-fmt
pkgs'.hlint
pkgs'.nixpkgs-fmt
pkgs'.haskellPackages.fourmolu
hls
];
};
});
};
# OFFCHAIN / Testnet, Cardano, ...
offchain = rec {
ghcVersion = "ghc8107";
projectFor = system:
let
pkgs = nixpkgsFor system;
pkgs' = nixpkgsFor' system;
plutipin = inputs.plutip.inputs;
project = pkgs.haskell-nix.cabalProject' {
src = ./offchain;
compiler-nix-name = ghcVersion;
inherit (plutip) cabalProjectLocal;
extraSources = plutip.extraSources ++ [
{
src = "${plutip}";
subdirs = [ "." ];
}
{
src = inputs.ply;
subdirs = [ "ply-core" ];
}
];
modules = [
({ config, ... }: {
packages.template-project-offchain.components.tests.template-project-offchain-test.build-tools = [
project.hsPkgs.cardano-cli.components.exes.cardano-cli
project.hsPkgs.cardano-node.components.exes.cardano-node
];
})
] ++ plutip.haskellModules;
shell = {
withHoogle = true;
exactDeps = true;
# We use the ones from Nixpkgs, since they are cached reliably.
# Eventually we will probably want to build these with haskell.nix.
nativeBuildInputs = [
pkgs'.cabal-install
pkgs'.fd
pkgs'.haskellPackages.apply-refact
pkgs'.haskellPackages.cabal-fmt
pkgs'.hlint
pkgs'.nixpkgs-fmt
pkgs'.haskellPackages.fourmolu
project.hsPkgs.cardano-cli.components.exes.cardano-cli
project.hsPkgs.cardano-node.components.exes.cardano-node
];
tools.haskell-language-server = { };
additional = ps: [
ps.plutip
ps.ply-core
];
};
};
in
project;
};
in
{
inherit nixpkgsFor;
onchain = {
project = perSystem onchain.projectFor;
flake = perSystem (system: (onchain.projectFor system).flake { });
};
offchain = {
project = perSystem offchain.projectFor;
flake = perSystem (system: (offchain.projectFor system).flake { });
};
packages = perSystem (system:
self.onchain.flake.${system}.packages
// self.offchain.flake.${system}.packages
);
devShells = perSystem (system: {
onchain = self.onchain.flake.${system}.devShell;
offchain = self.offchain.flake.${system}.devShell;
});
};
}