forked from runtimeverification/wasm-semantics
-
Notifications
You must be signed in to change notification settings - Fork 5
/
flake.nix
112 lines (96 loc) · 3.38 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
{
description = "K Semantics of WebAssembly";
inputs = {
k-framework.url = "github:runtimeverification/k/v7.1.149";
nixpkgs.follows = "k-framework/nixpkgs";
flake-utils.follows = "k-framework/flake-utils";
rv-utils.follows = "k-framework/rv-utils";
poetry2nix.follows = "k-framework/poetry2nix";
};
outputs = { self, k-framework, nixpkgs, flake-utils, rv-utils, ... }@inputs:
let
overlay = (final: prev:
let
src = prev.lib.cleanSource (prev.nix-gitignore.gitignoreSourcePure [
"/.github"
"flake.lock"
./.gitignore
] ./.);
poetry2nix = inputs.poetry2nix.lib.mkPoetry2Nix { pkgs = prev; };
version = self.rev or "dirty";
in {
kwasm = prev.stdenv.mkDerivation {
pname = "kwasm";
inherit src version;
buildInputs = with prev; [ k final.kwasm-pyk python310 ];
nativeBuildInputs = [ prev.makeWrapper ];
enableParallelBuilding = true;
buildPhase = ''
export XDG_CACHE_HOME=$(pwd)
kdist -v build -j4
'';
installPhase = ''
mkdir -p $out
cp -r ./kdist-*/* $out/
mkdir -p $out/bin
makeWrapper ${final.kwasm-pyk}/bin/kwasm $out/bin/kwasm \
--prefix PATH : ${prev.lib.makeBinPath [ prev.which prev.k ]} \
--set KDIST_DIR $out
'';
};
kwasm-pyk = poetry2nix.mkPoetryApplication {
python = prev.python310;
projectDir = ./pykwasm;
overrides = poetry2nix.overrides.withDefaults
(finalPython: prevPython: {
kframework = prev.pyk-python310;
py-wasm = prevPython.py-wasm.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ])
++ [ prevPython.setuptools ];
});
});
checkGroups = [ ];
};
kwasm-test = prev.stdenv.mkDerivation {
inherit version;
pname = "kwasm-test";
src = final.kwasm.src;
buildInputs = with final; [ kwasm kwasm-pyk which git ];
patchPhase = with final; ''
substituteInPlace Makefile \
--replace-fail '$(TEST)' '${kwasm}/bin/kwasm' \
--replace-fail '$(KDIST)' '${pyk-python310}/bin/kdist' \
--replace-fail '$(SOURCE_DIR)' '${kwasm}/wasm-semantics/source'
'';
buildPhase = ''
export XDG_CACHE_HOME=$(pwd)
make \
NIX=1 \
-j$NIX_BUILD_CORES \
test
'';
installPhase = ''
touch $out
'';
};
});
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.overlay overlay ];
};
in {
packages = rec {
inherit (pkgs) kwasm kwasm-pyk kwasm-test;
default = kwasm;
};
}) // {
overlays.default = overlay;
};
}