12 stdenv.mkDerivation rec {
16 src = fetchFromGitHub {
20 fetchSubmodules = true;
21 hash = "sha256-bmzkXbR4KSnpfXjs2MAx8mbNSbNrIWDP/O8S+JGWrcg=";
25 substituteInPlace stan/lib/stan_math/make/libraries \
26 --replace "/usr/bin/env bash" "bash"
35 patchShebangs test-all.sh runCmdStanTests.py stan/
37 # Fix inclusion of hardcoded paths in PCH files, by building in the store.
40 cp -R . $out/opt/cmdstan
43 ln -s ${buildPackages.stanc}/bin/stanc bin/stanc
48 ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
49 "arch=${stdenv.hostPlatform.darwinArch}"
52 # Disable inclusion of timestamps in PCH files when using Clang.
53 env.CXXFLAGS = lib.optionalString stdenv.cc.isClang "-Xclang -fno-pch-timestamp";
55 enableParallelBuilding = true;
61 ln -s $out/opt/cmdstan/bin/stanc $out/bin/stanc
62 ln -s $out/opt/cmdstan/bin/stansummary $out/bin/stansummary
63 cat > $out/bin/stan <<EOF
65 make -C $out/opt/cmdstan "\$(realpath "\$1")"
67 chmod a+x $out/bin/stan
73 test = runCommandCC "cmdstan-test" { } ''
74 cp -R ${cmdstan}/opt/cmdstan cmdstan
77 ./runCmdStanTests.py -j$NIX_BUILD_CORES src/test/interface
83 description = "Command-line interface to Stan";
85 Stan is a probabilistic programming language implementing full Bayesian
86 statistical inference with MCMC sampling (NUTS, HMC), approximate Bayesian
87 inference with Variational inference (ADVI) and penalized maximum
88 likelihood estimation with Optimization (L-BFGS).
90 homepage = "https://mc-stan.org/interfaces/cmdstan.html";
91 license = licenses.bsd3;
92 maintainers = with maintainers; [ wegank ];
93 platforms = platforms.unix;