nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 rustPlatform,
5 fetchFromGitHub,
6 nodejs,
7 nodejs_20,
8 makeWrapper,
9 jre,
10 fetchzip,
11 buildNpmPackage,
12}:
13
14let
15 version = "0.25.1";
16 apalacheVersion = "0.47.2";
17 evaluatorVersion = "0.2.0";
18
19 metaCommon = {
20 description = "Formal specification language with TLA+ semantics";
21 homepage = "https://quint-lang.org";
22 license = lib.licenses.asl20;
23 platforms = lib.platforms.unix;
24 maintainers = with lib.maintainers; [ bugarela ];
25 };
26
27 src = fetchFromGitHub {
28 owner = "informalsystems";
29 repo = "quint";
30 tag = "v${version}";
31 hash = "sha256-CYQesIoDlIGCKXIJ/hpZqOZBVd19Or5VEKVERchJz68=";
32 };
33
34 # Build the Quint CLI from source
35 quint-cli = buildNpmPackage {
36 pname = "quint-cli";
37 inherit version src;
38
39 nativeBuildInputs = [ nodejs_20 ];
40
41 sourceRoot = "${src.name}/quint";
42
43 npmDepsHash = "sha256-FYNSr5B0/oJ4PbU/HUVqSdPG8kFvq4vRFnYwwdMf+jQ=";
44
45 npmBuildScript = "compile";
46
47 dontNpmPrune = true;
48
49 installPhase = ''
50 runHook preInstall
51
52 mkdir -p $out/share/quint
53 cp -r node_modules $out/share/quint
54 cp -r dist $out/share/quint
55
56 runHook postInstall
57 '';
58
59 meta = metaCommon // {
60 description = "CLI for the Quint formal specification language";
61 };
62 };
63
64 # Build the Rust evaluator from source
65 quint-evaluator = rustPlatform.buildRustPackage {
66 pname = "quint-evaluator";
67 version = evaluatorVersion;
68 inherit src;
69
70 sourceRoot = "${src.name}/evaluator";
71
72 # Skip tests during build, as many rust tests rely on the Quint CLI
73 doCheck = false;
74
75 cargoHash = "sha256-beWqUDaWWCbGL+V1LNtf35wZrIqWCCbFLYo5HCZF7FI=";
76
77 meta = metaCommon // {
78 description = "Evaluator for the Quint formal specification language";
79 };
80 };
81
82 # Download Apalache. It runs on the JVM, so no need to build it from source.
83 apalacheDist = fetchzip {
84 url = "https://github.com/apalache-mc/apalache/releases/download/v${apalacheVersion}/apalache.tgz";
85 hash = "sha256-P0QOxB14OSlphqBALR1YL9WJ0XYaUYE/R52yZytVzds=";
86 };
87in
88stdenv.mkDerivation (finalAttrs: {
89 pname = "quint";
90 inherit version src;
91
92 nativeBuildInputs = [ makeWrapper ];
93
94 dontBuild = true;
95
96 dontConfigure = true;
97
98 installPhase = ''
99 runHook preInstall
100
101 mkdir -p $out/bin
102 makeWrapper ${nodejs}/bin/node $out/bin/quint \
103 --add-flags "${quint-cli}/share/quint/dist/src/cli.js" \
104 --set QUINT_HOME "$out/share/quint" \
105 --prefix PATH : ${lib.makeBinPath [ jre ]}
106
107 install -Dm755 ${quint-evaluator}/bin/quint_evaluator -t $out/share/quint/rust-evaluator-v${evaluatorVersion}/
108
109 mkdir -p $out/share/quint/apalache-dist-${apalacheVersion}
110 cp -r ${apalacheDist} $out/share/quint/apalache-dist-${apalacheVersion}/apalache
111 chmod +x $out/share/quint/apalache-dist-${apalacheVersion}/apalache/bin/apalache-mc
112
113 runHook postInstall
114 '';
115
116 meta = metaCommon // {
117 mainProgram = "quint";
118 };
119})