1{ stdenv, fetchurl, python }:
2
3stdenv.mkDerivation rec {
4 name = "cmdstan-2.9.0";
5
6 src = fetchurl {
7 url = "https://github.com/stan-dev/cmdstan/releases/download/v2.9.0/cmdstan-2.9.0.tar.gz";
8 sha256 = "08bim6nxgam989152hm0ga1rfb33mr71pwsym1nmfmavma68bwm9";
9 };
10
11 buildFlags = "build";
12 enableParallelBuilding = true;
13 nativeBuildInputs = stdenv.lib.optional doCheck python;
14
15 doCheck = true;
16 checkPhase = "python ./runCmdStanTests.py src/test/interface"; # see #5368
17
18 installPhase = ''
19 mkdir -p $out/opt $out/bin
20 cp -r . $out/opt/cmdstan
21 ln -s $out/opt/cmdstan/bin/stanc $out/bin/stanc
22 ln -s $out/opt/cmdstan/bin/stansummary $out/bin/stansummary
23 cat > $out/bin/stan <<EOF
24 #!/bin/sh
25 make -C $out/opt/cmdstan "\$(realpath "\$1")"
26 EOF
27 chmod a+x $out/bin/stan
28 '';
29
30 meta = {
31 description = "Command-line interface to Stan";
32 longDescription = ''
33 Stan is a probabilistic programming language implementing full Bayesian
34 statistical inference with MCMC sampling (NUTS, HMC), approximate Bayesian
35 inference with Variational inference (ADVI) and penalized maximum
36 likelihood estimation with Optimization (L-BFGS).
37 '';
38 homepage = http://mc-stan.org/interfaces/cmdstan.html;
39 license = stdenv.lib.licenses.bsd3;
40 platforms = stdenv.lib.platforms.linux;
41 };
42}