-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathflake.nix
218 lines (213 loc) · 8.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
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
207
208
209
210
211
212
213
214
215
216
217
218
{
# nix build .
# nix develop
# nix run . [runs llvm-disasm]
#
# nix run github:galoisinc/llvm-pretty-bc-parser [runs llvm-disasm]
description = "Flake to build the haskell-src package 'llvm-pretty-bc-parser' and dependencies";
nixConfig.bash-prompt-suffix = "llvm-pretty-bc-parser.env} ";
inputs = {
nixpkgs-ghc8 = { url = "github:nixos/nixpkgs/23.05"; };
nixpkgs = { url = "github:nixos/nixpkgs/nixpkgs-unstable"; };
levers = {
url = "github:kquick/nix-levers";
inputs.nixpkgs.follows = "nixpkgs";
};
llvm-pretty-src = {
url = "github:GaloisInc/llvm-pretty";
flake = false;
};
fgl-src = {
url = "https://hackage.haskell.org/package/fgl-5.8.2.0/fgl-5.8.2.0.tar.gz";
flake = false;
};
fgl-visualize-src = {
url = "https://hackage.haskell.org/package/fgl-visualize-0.1.0.1/fgl-visualize-0.1.0.1.tar.gz";
flake = false;
};
optparse-applicative-src = {
url = "github:pcapriotti/optparse-applicative/0.18.1";
flake = false;
};
tasty-src = {
url = "github:UnkindPartition/tasty/core-1.4.3";
flake = false;
};
tasty-expected-failure-src = {
url = "github:nomeata/tasty-expected-failure";
flake = false;
};
tasty-sugar = {
url = "github:kquick/tasty-sugar";
inputs.nixpkgs.follows = "nixpkgs";
inputs.levers.follows = "levers";
inputs.optparse-applicative-src.follows = "optparse-applicative-src";
inputs.tasty-src.follows = "tasty-src";
};
};
outputs = { self, levers, nixpkgs, nixpkgs-ghc8
, llvm-pretty-src
, fgl-src
, fgl-visualize-src
, optparse-applicative-src
, tasty-src
, tasty-expected-failure-src
, tasty-sugar
}:
let
shellWith = pkgs: adds: drv: drv.overrideAttrs(old:
{ buildInputs = old.buildInputs ++ adds pkgs; });
# Add additional packages useful for a development shell, generally
# representing test packages or non-propagated build dependencies of
# various sub-packages.
shellPkgs = pkgs: [
# pkgs.haskell.compiler.integer-simple.ghc8107
# pkgs.haskell.packages.ghc8107.profiteur
pkgs.cabal-install
pkgs.llvm_11
pkgs.clang_11
];
in rec {
devShells =
let oneshell = s: n:
let pkgs = import nixpkgs { system=s; };
in levers.variedTargets
{ ghcver = levers.validGHCVersions pkgs.haskell.compiler; }
( { ghcver, ... } @ vargs:
shellWith pkgs shellPkgs
(self.packages.${s}.${n}.${ghcver}.env.overrideAttrs (a:
{
# Set envvars here
}
)));
in levers.eachSystem
(s:
let pkgs = import nixpkgs { system=s; };
names = builtins.attrNames (self.packages.${s});
outs = builtins.removeAttrs
(pkgs.lib.genAttrs names (oneshell s))
[ "ghc" ];
shells = pkgs.lib.attrsets.mapAttrs (n: v: v.default) outs;
in shells // { default = devShells.${s}.llvm-pretty-bc-parser-test-build; }
) ;
packages = levers.eachSystem (system:
let
mkHaskellGhc9 = levers.mkHaskellPkg {
inherit nixpkgs system;
};
mkHaskellGhc8 = levers.mkHaskellPkg {
inherit system;
nixpkgs = nixpkgs-ghc8;
};
mkHaskell = name: src: ovrDrvOrArgs:
let blds8 = mkHaskellGhc8 name src ovrDrvOrArgs;
blds9 = mkHaskellGhc9 name src ovrDrvOrArgs;
in (blds8 // blds9);
pkgs = import nixpkgs-ghc8 { inherit system; };
wrap = levers.pkg_wrapper system pkgs;
haskellAdj = drv:
with (pkgs.haskell).lib;
dontHaddock (dontCheck (dontBenchmark (drv)));
llvm-pretty-bc-parser-test = built: llvmver:
let llvm = pkgs."llvm_${llvmver}";
clang = pkgs."clang_${llvmver}";
in derivation {
inherit system;
name = "llvm-pretty-bc-parser-test-with-llvm${llvmver}";
builder = "${pkgs.bash}/bin/bash";
args = [ "-c"
''
${pkgs.coreutils}/bin/cp -r ${built}/test-build/* .
export PATH=${llvm}/bin:${clang}/bin:${pkgs.diffutils}/bin:$PATH
set -e
echo Running unit-test
./dist/build/unit-test/unit-test
echo Running disasm-test
./dist/build/disasm-test/disasm-test
echo Finished testing
echo OK > $out
''
];
buildInputs = [ clang llvm pkgs.diffutils pkgs.coreutils ];
hardeningDisable = [ "all" ]; # tests will build with -O0
};
in rec {
default = llvm-pretty-bc-parser;
TESTS = wrap "llvm-pretty-bc-parser-TESTS"
(builtins.map
(llvm-pretty-bc-parser-test llvm-pretty-bc-parser-test-build)
[
# NOTE: this is the main location which determines what LLVM
# versions are tested. The default is to run each of the listed
# LLVM versions here in parallel.
"10"
"11"
"12"
"13"
"14"
"15"
"16"
]
);
TESTS_PREP = wrap "llvm-pretty-bc-parser-TESTS_PREP"
[ llvm-pretty-bc-parser-test-build ];
DOC = wrap "llvm-pretty-bc-parser-DOC"
[ llvm-pretty-bc-parser-doc ];
fgl = mkHaskell "fgl" fgl-src {
adjustDrv = args: haskellAdj;
};
fgl-visualize = mkHaskell "fgl-visualize" fgl-visualize-src {
inherit fgl;
adjustDrv = args: haskellAdj;
};
llvm-pretty = mkHaskell "llvm-pretty" llvm-pretty-src {
adjustDrv = args: haskellAdj;
};
llvm-pretty-bc-parser = mkHaskell "llvm-pretty-bc-parser" self {
inherit llvm-pretty fgl fgl-visualize;
adjustDrv = args: haskellAdj;
};
llvm-pretty-bc-parser-test-build = mkHaskell "llvm-pretty-bc-parser-test-build" self {
inherit llvm-pretty optparse-applicative tasty-sugar
tasty tasty-quickcheck tasty-expected-failure tasty-hunit;
adjustDrv = args: drv:
with pkgs.haskell.lib;
(doCheck (haskellAdj drv)).overrideAttrs (a:
{ checkPhase = "echo skipping checks";
postInstall = ''
mkdir $out/test-build
cp llvm-pretty-bc-parser.cabal $out/test-build
mkdir $out/test-build/disasm-test
cp -r disasm-test/tests $out/test-build/disasm-test
cp -r disasm-test/known_bugs $out/test-build/disasm-test
cp -r dist $out/test-build/
'';
});
};
llvm-pretty-bc-parser-doc = mkHaskell "llvm-pretty-bc-parser-doc" self {
inherit llvm-pretty;
adjustDrv = args: drv:
pkgs.haskell.lib.dontCheck (pkgs.haskell.lib.dontBenchmark drv);
};
optparse-applicative = mkHaskell "optparse-applicative" optparse-applicative-src {
adjustDrv = args: haskellAdj;
};
tasty = mkHaskell "tasty" "${tasty-src}/core" {
inherit optparse-applicative;
adjustDrv = args: haskellAdj;
};
tasty-expected-failure = mkHaskell "tasty-expected-failure" "${tasty-expected-failure-src}" {
inherit tasty;
adjustDrv = args: haskellAdj;
};
tasty-hunit = mkHaskell "tasty-hunit" "${tasty-src}/hunit" {
inherit tasty;
adjustDrv = args: haskellAdj;
};
tasty-quickcheck = mkHaskell "tasty-quickcheck" "${tasty-src}/quickcheck" {
inherit optparse-applicative tasty;
adjustDrv = args: haskellAdj;
};
});
};
}