-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
191 lines (171 loc) · 5.73 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
{
description = "kmxwasm - Symbolic execution for the MulitversX blockchain with the Wasm semantics, using pyk.";
inputs = {
k-framework.url = "github:runtimeverification/k/v7.1.85";
pyk.url = "github:runtimeverification/k/v7.1.85?dir=pyk";
nixpkgs-pyk.follows = "pyk/nixpkgs";
poetry2nix.follows = "pyk/poetry2nix";
mx-semantics.url = "github:runtimeverification/mx-semantics/v0.1.107";
nixpkgs.follows = "k-framework/nixpkgs";
flake-utils.follows = "k-framework/flake-utils";
rv-utils.url = "github:runtimeverification/rv-nix-tools";
blockchain-k-plugin.follows = "mx-semantics/blockchain-k-plugin";
mx-sdk-rs.url = "github:runtimeverification/mx-sdk-rs-flake/v0.50.3";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
mx-sdk-rs-src = {
url = "github:multiversx/mx-sdk-rs/v0.50.3";
flake = false;
};
coindrip-protocol-sc-src = {
url = "github:CoinDrip-finance/coindrip-protocol-sc/v1.0.1";
flake = false;
};
mx-exchange-sc-src = {
url = "github:multiversx/mx-exchange-sc/ee2d4645bd13c0f22f668a72bbc1b883753b6aee";
flake = false;
};
};
outputs = { self, nixpkgs, flake-utils, rv-utils, k-framework, pyk, nixpkgs-pyk, mx-semantics, blockchain-k-plugin, mx-sdk-rs, rust-overlay, ... }@inputs:
let overlay = (final: prev:
let
src = prev.lib.cleanSource (prev.nix-gitignore.gitignoreSourcePure [
"/.github"
"flake.lock"
./.gitignore
] ./.);
version = self.rev or "dirty";
nixpkgs-pyk = import inputs.nixpkgs-pyk {
system = prev.system;
overlays = [ pyk.overlay ];
};
python310-pyk = nixpkgs-pyk.python310;
poetry2nix = inputs.poetry2nix.lib.mkPoetry2Nix { pkgs = nixpkgs-pyk; };
in {
kmxwasm-pyk = poetry2nix.mkPoetryApplication {
python = nixpkgs-pyk.python310;
projectDir = ./kmxwasm;
src = rv-utils.lib.mkSubdirectoryAppSrc {
pkgs = import nixpkgs { system = prev.system; };
src = ./kmxwasm;
subdirectories = [ "kmultiversx" ];
cleaner = poetry2nix.cleanPythonSources;
};
patchPhase = ''
sed -i "s/^ROOT = .*$/ROOT = Path('.')/" src/kmxwasm/property_testing/paths.py
'';
overrides = poetry2nix.overrides.withDefaults
(finalPython: prevPython: {
pyk = nixpkgs-pyk.pyk-python310;
kmultiversx = final.kmultiversx-pyk;
});
groups = [ ];
checkGroups = [ ];
postInstall = ''
mkdir -p $out/${nixpkgs-pyk.python310.sitePackages}/kmxwasm/kdist/plugin
cp -r ${prev.blockchain-k-plugin-src}/* $out/${nixpkgs-pyk.python310.sitePackages}/kmxwasm/kdist/plugin/
'';
};
kmxwasm = prev.stdenv.mkDerivation {
pname = "kmxwasm";
inherit src version;
buildInputs = with final; [
secp256k1
nixpkgs-pyk.pyk-python310
k-framework.packages.${system}.k
kmultiversx-pyk
kmxwasm-pyk
cmake
openssl.dev
clang
mpfr
pkg-config
procps
llvmPackages.llvm
];
dontUseCmakeConfigure = true;
nativeBuildInputs = [ prev.makeWrapper ];
enableParallelBuilding = true;
buildPhase = ''
export XDG_CACHE_HOME=$(pwd)
export K_OPTS="-Xmx8G -Xss512m"
export APPLE_SILICON=${
prev.lib.optionalString
(prev.stdenv.isAarch64 && prev.stdenv.isDarwin)
"true"
}
kdist -v build \
-j$NIX_BUILD_CORES \
"mxwasm-semantics.*" \
"mx-semantics.llvm-kasmer"
'';
installPhase = ''
mkdir -p $out
cp -r ./kdist-*/* $out/
mkdir -p $out/bin
makeWrapper ${final.kmxwasm-pyk}/bin/kasmer $out/bin/kasmer \
--prefix PATH : ${
prev.lib.makeBinPath [
prev.which
k-framework.packages.${prev.system}.k
]
} \
--set KDIST_DIR $out
'';
};
kmxwasm-test-shell = prev.mkShell {
packages = with final; [
(rust-bin.stable.latest.default.override {
targets = [ "wasm32-unknown-unknown" ];
})
mx-sdk-rs.packages.${system}.sc-meta
wabt
kmxwasm
];
buildInputs = with final; [
cacert
pkg-config
openssl
] ++ (lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.SystemConfiguration);
shellHook = ''
export CARGO_HOME=$(pwd)
export USE_NIX=true
'';
};
}
);
in flake-utils.lib.eachSystem [
"x86_64-linux"
"x86_64-darwin"
"aarch64-linux"
"aarch64-darwin"
] (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
rust-overlay.overlays.default
k-framework.overlay
blockchain-k-plugin.overlay
mx-semantics.overlays.default
overlay
];
};
in {
packages = {
inherit (pkgs) kmxwasm kmxwasm-test-shell;
default = pkgs.kmxwasm;
};
devShell = pkgs.mkShell {
buildInputs = with pkgs; [
k-framework.packages.${pkgs.system}.k
poetry
wabt
];
};
}) // {
overlays.default = overlay;
};
}