-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathflake.nix
152 lines (140 loc) · 5.2 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
{
description = "K Semantics of MultiversX";
inputs = {
wasm-semantics.url = "github:runtimeverification/wasm-semantics/v0.1.106";
k-framework.follows = "wasm-semantics/k-framework";
nixpkgs.follows = "k-framework/nixpkgs";
flake-utils.follows = "k-framework/flake-utils";
rv-utils.follows = "k-framework/rv-utils";
poetry2nix.follows = "k-framework/poetry2nix";
blockchain-k-plugin = {
url =
"github:runtimeverification/blockchain-k-plugin/c9264b240c00d1f6cc20e22aac83c94d1a499138";
inputs.flake-utils.follows = "k-framework/flake-utils";
inputs.nixpkgs.follows = "k-framework/nixpkgs";
};
};
outputs = { self, k-framework, nixpkgs, flake-utils, rv-utils
, 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";
poetry2nix =
inputs.poetry2nix.lib.mkPoetry2Nix { pkgs = prev; };
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
prev.python310
k-framework.packages.${system}.k
kmultiversx-pyk
boost
cmake
openssl.dev
clang
mpfr
pkg-config
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 = prev.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 = prev.pyk-python310.overridePythonAttrs
(old: {
propagatedBuildInputs = prev.lib.filter (x:
!(prev.lib.strings.hasInfix "hypothesis" x.name)
&& !(prev.lib.strings.hasInfix "cmd2" x.name))
old.propagatedBuildInputs
++ [ finalPython.hypothesis finalPython.cmd2 ];
});
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 ];
});
py-wasm = prevPython.py-wasm.overridePythonAttrs
(old: {
buildInputs = (old.buildInputs or [ ])
++ [ prevPython.setuptools ];
});
});
groups = [ ];
checkGroups = [ ];
postInstall = ''
mkdir -p $out/${prev.python310.sitePackages}/kmultiversx/kdist/plugin
cp -r ${prev.blockchain-k-plugin-src}/* $out/${prev.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 = [ k-framework.overlays.pyk blockchain-k-plugin.overlay overlay ];
};
in {
packages = rec {
inherit (pkgs) kmultiversx kmultiversx-pyk;
default = pkgs.kmultiversx;
};
}) // {
overlays.default = overlay;
};
}