-
Notifications
You must be signed in to change notification settings - Fork 42
/
flake.nix
206 lines (199 loc) · 8.17 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
{
description = "K Kore Language Haskell Backend";
inputs = {
rv-utils.url = "github:runtimeverification/rv-nix-tools";
nixpkgs.follows = "rv-utils/nixpkgs";
stacklock2nix.url = "github:cdepillabout/stacklock2nix";
z3 = {
url = "github:Z3Prover/z3/z3-4.13.0";
flake = false;
};
};
outputs = { self, nixpkgs, stacklock2nix, z3, rv-utils }:
let
perSystem = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed;
nixpkgsCleanFor = system: import nixpkgs { inherit system; };
nixpkgsFor = system:
import nixpkgs {
inherit system;
overlays = [ stacklock2nix.overlay self.overlay self.overlays.z3 ];
};
withZ3 = pkgs: pkg: exe:
pkgs.stdenv.mkDerivation {
name = exe;
phases = [ "installPhase" ];
buildInputs = with pkgs; [ makeWrapper ];
installPhase = ''
mkdir -p $out/bin
makeWrapper ${pkg}/bin/${exe} $out/bin/${exe} --prefix PATH : ${pkgs.z3}/bin
'';
};
# This should based on the compiler version from the resolver in stack.yaml.
ghcVersion = pkgs: pkgs.haskell.packages.ghc965;
in {
overlay = final: prev: {
haskell-backend = final.stacklock2nix {
stackYaml = ./stack.yaml;
# This should based on the compiler version from the resolver in stack.yaml.
baseHaskellPkgSet = ghcVersion final;
cabal2nixArgsOverrides = args:
args // {
# The Haskell package `"graphviz"` depends on the _system_
# package `graphviz`, and takes the system package `graphviz` as one of its build
# inputs, but it is actually getting passed _itself_ (not the system package
# `graphviz`), which causes the infinite recursion.
"graphviz" = _: { graphviz = final.graphviz; };
};
additionalHaskellPkgSetOverrides = hfinal: hprev:
with final.haskell.lib; {
crypton-x509 = dontCheck hprev.crypton-x509;
data-fix = doJailbreak hprev.data-fix;
decision-diagrams = dontCheck hprev.decision-diagrams;
fgl = dontCheck hprev.fgl;
fgl-arbitrary = dontCheck hprev.fgl-arbitrary;
graphviz = dontCheck hprev.graphviz;
json-rpc = dontCheck hprev.json-rpc;
lifted-base = dontCheck hprev.lifted-base;
prettyprinter = dontCheck hprev.prettyprinter;
semialign = doJailbreak hprev.semialign;
smtlib-backends-process = dontCheck hprev.smtlib-backends-process;
tar = dontCheck hprev.tar;
text-short = doJailbreak hprev.text-short;
these = doJailbreak hprev.these;
ghc-prof = doJailbreak hprev.ghc-prof;
hs-backend-booster = overrideCabal hprev.hs-backend-booster
(drv: {
doCheck = false;
postPatch = ''
${drv.postPatch or ""}
substituteInPlace library/Booster/VersionInfo.hs \
--replace '$(GitRev.gitHash)' '"${self.rev or "dirty"}"'
'';
});
kore = (overrideCabal hprev.kore (drv: {
doCheck = false;
postPatch = ''
${drv.postPatch or ""}
substituteInPlace src/Kore/VersionInfo.hs \
--replace '$(GitRev.gitHash)' '"${self.rev or "dirty"}"'
'';
postInstall = ''
${drv.postInstall or ""}
'';
})).override {
# bit pathological, but ghc-compact is already included with the ghc compiler
# and depending on another copy of ghc-compact breaks HLS in the dev shell.
ghc-compact = null;
};
};
# Additional packages that should be available for development.
additionalDevShellNativeBuildInputs = stacklockHaskellPkgSet:
with ghcVersion final; [
cabal-install
hpack
fourmolu
hlint
final.haskell-language-server
final.z3
final.secp256k1
];
# nix expects all inputs downloaded from the internet to have a hash,
# so hackage is periodically downloaded, hashed and the hashes stored in a map.
# this need to be bumped if changing the stack resolver
all-cabal-hashes = final.fetchurl {
url =
"https://github.com/commercialhaskell/all-cabal-hashes/archive/ce857734d7d4c0fad3f6dda3a4db052836ed4619.tar.gz";
sha256 = "sha256-Q7Zg32v5ubjVJMQXGiyyMmeFg08jTzVRKC18laiHCPE=";
};
};
};
prelude-kore = ./src/main/kore/prelude.kore;
packages = perSystem (system:
let
pkgs = nixpkgsFor system;
kore = with pkgs;
haskell.lib.justStaticExecutables haskell-backend.pkgSet.kore;
hs-backend-booster = with pkgs;
haskell.lib.justStaticExecutables haskell-backend.pkgSet.hs-backend-booster;
hs-backend-booster-dev-tools = with pkgs;
haskell.lib.justStaticExecutables haskell-backend.pkgSet.hs-backend-booster-dev-tools;
in {
kore-exec = withZ3 pkgs kore "kore-exec";
kore-match-disjunction = withZ3 pkgs hs-backend-booster-dev-tools "kore-match-disjunction";
kore-parser = withZ3 pkgs hs-backend-booster-dev-tools "kore-parser";
kore-repl = withZ3 pkgs kore "kore-repl";
kore-rpc = withZ3 pkgs kore "kore-rpc";
kore-rpc-booster = withZ3 pkgs hs-backend-booster "kore-rpc-booster";
kore-rpc-client = withZ3 pkgs hs-backend-booster "kore-rpc-client";
booster-dev = withZ3 pkgs hs-backend-booster-dev-tools "booster-dev";
inherit (pkgs.haskell-backend.pkgSet) haskell-language-server;
});
devShells = perSystem (system: {
# Separate fourmolu and cabal shells just for CI
style = with nixpkgsCleanFor system;
mkShell {
nativeBuildInputs = [
(haskell.lib.justStaticExecutables
(ghcVersion pkgs).fourmolu)
(haskell.lib.justStaticExecutables
(ghcVersion pkgs).hlint)
pkgs.hpack
];
shellHook = ''
hpack booster && hpack dev-tools
'';
};
cabal = let pkgs = nixpkgsFor system;
in pkgs.haskell-backend.pkgSet.shellFor {
packages = pkgs.haskell-backend.localPkgsSelector;
nativeBuildInputs = [
(ghcVersion pkgs).cabal-install
pkgs.hpack
pkgs.jq
pkgs.nix
pkgs.z3
pkgs.lsof
];
shellHook = ''
hpack booster && hpack dev-tools
'';
};
});
devShell =
perSystem (system: (nixpkgsFor system).haskell-backend.devShell);
overlays = {
z3 = (final: prev: {
z3 = prev.z3.overrideAttrs (_: {
src = z3;
version = let
release = builtins.readFile "${z3}/scripts/release.yml";
# Read the release version from scripts/release.yml
in builtins.head
(builtins.match ".+ReleaseVersion: '([^']+).+" release);
});
});
integration-tests = (final: prev: {
kore-tests = final.callPackage ./nix/integration-shell.nix {
python = final.python3.withPackages (ps:
with ps;
[
(buildPythonPackage rec {
pname = "jsonrpcclient";
version = "4.0.3";
src = prev.fetchFromGitHub {
owner = "explodinglabs";
repo = pname;
rev = version;
sha256 =
"sha256-xqQwqNFXatGzc4JprZY1OpdPPGgpP5/ucG/qyV/n8hw=";
};
doCheck = false;
format = "pyproject";
buildInputs = [ setuptools ];
})
]);
};
});
};
};
}