1{ stdenv, fetchurl }:
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
14 doCheck = true;
15 checkPhase = "./runCmdStanTests.py src/test/interface";
16
17 installPhase = ''
18 mkdir -p $out/opt $out/bin
19 cp -r . $out/opt/cmdstan
20 ln -s $out/opt/cmdstan/bin/stanc $out/bin/stanc
21 ln -s $out/opt/cmdstan/bin/stansummary $out/bin/stansummary
22 cat > $out/bin/stan <<EOF
23 #!/bin/sh
24 make -C $out/opt/cmdstan "\$(realpath "\$1")"
25 EOF
26 chmod a+x $out/bin/stan
27 '';
28
29 meta = {
30 description = "Command-line interface to Stan";
31 longDescription = ''
32 Stan is a probabilistic programming language implementing full Bayesian
33 statistical inference with MCMC sampling (NUTS, HMC), approximate Bayesian
34 inference with Variational inference (ADVI) and penalized maximum
35 likelihood estimation with Optimization (L-BFGS).
36 '';
37 homepage = http://mc-stan.org/interfaces/cmdstan.html;
38 license = stdenv.lib.licenses.bsd3;
39 };
40}