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