forked from runtimeverification/mx-semantics
-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
159 lines (144 loc) · 5.25 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
{
description = "K Semantics of MultiversX";
inputs = {
wasm-semantics.url = "github:runtimeverification/wasm-semantics/v0.1.95";
k-framework.url = "github:runtimeverification/k/v7.1.85";
pyk.url = "github:runtimeverification/k/v7.1.85?dir=pyk";
nixpkgs.follows = "k-framework/nixpkgs";
flake-utils.follows = "k-framework/flake-utils";
rv-utils.url = "github:runtimeverification/rv-nix-tools";
nixpkgs-pyk.follows = "pyk/nixpkgs";
poetry2nix.follows = "pyk/poetry2nix";
blockchain-k-plugin = {
url =
"github:runtimeverification/blockchain-k-plugin/415b8ce8fa594f41ce3a3f29fc83e954284f81cf";
inputs.flake-utils.follows = "k-framework/flake-utils";
inputs.nixpkgs.follows = "k-framework/nixpkgs";
};
};
outputs =
{ self, k-framework, nixpkgs, flake-utils, rv-utils, pyk, nixpkgs-pyk, poetry2nix, wasm-semantics, blockchain-k-plugin }@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 {
kmultiversx-src = prev.stdenv.mkDerivation {
name = "kmultiversx-${self.rev or "dirty"}-src";
src = prev.lib.cleanSource
(prev.nix-gitignore.gitignoreSourcePure [
./.gitignore
".github/"
"result*"
"*.nix"
"deps/"
] ./.);
dontBuild = true;
installPhase = ''
mkdir $out
cp -r $src/* $out
chmod -R u+w $out
mkdir -p $out/kmultiversx/src/kmultiversx/kdist/plugin/
cp -r ${prev.blockchain-k-plugin-src}/* $out/kmultiversx/src/kmultiversx/kdist/plugin/
'';
};
kmultiversx = prev.stdenv.mkDerivation {
pname = "kmultiversx";
src = final.kmultiversx-src;
inherit version;
buildInputs = with final; [
secp256k1
nixpkgs-pyk.pyk-python310
k-framework.packages.${system}.k
kmultiversx-pyk
cmake
openssl.dev
clang
mpfr
pkg-config
procps
llvmPackages.llvm
];
dontUseCmakeConfigure = true;
nativeBuildInputs = [ prev.makeWrapper ];
enableParallelBuilding = true;
buildPhase = ''
export XDG_CACHE_HOME=$(pwd)
${
prev.lib.optionalString
(prev.stdenv.isAarch64 && prev.stdenv.isDarwin)
"APPLE_SILICON=true"
} K_OPTS="-Xmx8G -Xss512m" kdist -v build mx-semantics.* -j$NIX_BUILD_CORES
'';
installPhase = ''
mkdir -p $out
cp -r ./kdist-*/* $out/
'';
};
kmultiversx-pyk = poetry2nix.mkPoetryApplication {
python = nixpkgs-pyk.python310;
projectDir = ./kmultiversx;
src = rv-utils.lib.mkSubdirectoryAppSrc {
pkgs = import nixpkgs { system = prev.system; };
src = ./kmultiversx;
subdirectories = [ "pykwasm" ];
cleaner = poetry2nix.cleanPythonSources;
};
overrides = poetry2nix.overrides.withDefaults
(finalPython: prevPython: {
kframework = nixpkgs-pyk.pyk-python310.overridePythonAttrs
(old: {
propagatedBuildInputs = prev.lib.filter
(x: !(prev.lib.strings.hasInfix "hypothesis" x.name))
old.propagatedBuildInputs ++ [ finalPython.hypothesis ];
});
pykwasm =
wasm-semantics.packages.${prev.system}.kwasm-pyk.overridePythonAttrs
(old: {
propagatedBuildInputs = prev.lib.filter
(x: !(prev.lib.strings.hasInfix "kframework" x.name))
old.propagatedBuildInputs ++ [ finalPython.kframework ];
});
});
groups = [ ];
checkGroups = [ ];
postInstall = ''
mkdir -p $out/${nixpkgs-pyk.python310.sitePackages}/kmultiversx/kdist/plugin
cp -r ${prev.blockchain-k-plugin-src}/* $out/${nixpkgs-pyk.python310.sitePackages}/kmultiversx/kdist/plugin/
'';
};
});
in flake-utils.lib.eachSystem [
"x86_64-linux"
"x86_64-darwin"
"aarch64-linux"
"aarch64-darwin"
] (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
blockchain-k-plugin.overlay
overlay
];
};
in {
packages = rec {
inherit (pkgs) kmultiversx kmultiversx-pyk;
default = pkgs.kmultiversx;
};
}) // {
overlays.default = overlay;
};
}