1{ lib, rustPlatform, fetchFromGitHub, makeWrapper, z3, pkgsHostTarget }:
2
3let
4 runtimeDeps = [
5 z3
6 pkgsHostTarget.targetPackages.stdenv.cc
7 ];
8in
9
10rustPlatform.buildRustPackage rec {
11 pname = "zz";
12 version = "unstable-2021-05-04";
13
14 # when updating, choose commit of the latest build on http://bin.zetz.it/
15 src = fetchFromGitHub {
16 owner = "zetzit";
17 repo = "zz";
18 rev = "18020b10b933cfe2fc7f2256b71e646889f9b1d2";
19 sha256 = "01nlyyk1qxk76dq2hw3wpbjwkh27zzp6mpczjnxdpv6rxs7mc825";
20 };
21
22 nativeBuildInputs = [ makeWrapper ];
23
24 cargoLock = {
25 lockFile = ./Cargo.lock;
26 outputHashes = {
27 "rsmt2-0.11.0" = "sha256-RwNsS0zge8uOXmgzTvDwp8AD70NspIZq0LgW/v3yrpA=";
28 };
29 };
30
31 postPatch = ''
32 # remove search path entry which would reference /build
33 sed -i '/env!("CARGO_MANIFEST_DIR")/d' src/lib.rs
34 '';
35
36 postInstall = ''
37 mkdir -p "$out/share/zz"
38 cp -r modules "$out/share/zz/"
39
40 wrapProgram $out/bin/zz \
41 --prefix PATH ":" "${lib.makeBinPath runtimeDeps}" \
42 --suffix ZZ_MODULE_PATHS ":" "$out/share/zz/modules"
43 '';
44
45 meta = with lib; {
46 description = "ZetZ a zymbolic verifier and tranzpiler to bare metal C";
47 homepage = "https://github.com/zetzit/zz";
48 license = licenses.mit;
49 maintainers = [ maintainers.marsam ];
50 };
51}