nixpkgs/pkgs/development/compilers/cmdstan/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

60 lines
1.8 KiB
Nix
Raw Normal View History

2021-03-25 10:48:24 +00:00
{ lib, stdenv, fetchurl, python3, runtimeShell }:
2015-12-11 12:35:17 +00:00
stdenv.mkDerivation rec {
pname = "cmdstan";
2022-11-24 03:53:09 +00:00
version = "2.31.0";
2015-12-11 12:35:17 +00:00
2022-04-13 18:51:50 +00:00
# includes stanc binaries needed to build cmdstand
2015-12-11 12:35:17 +00:00
src = fetchurl {
url = "https://github.com/stan-dev/cmdstan/releases/download/v${version}/cmdstan-${version}.tar.gz";
2022-11-24 03:53:09 +00:00
sha256 = "sha256-BMqRRWIC/Z7It2qkESJd9L3ycyxvA6NHiWbAvzVMzIQ=";
2015-12-11 12:35:17 +00:00
};
buildFlags = [ "build" ];
2015-12-11 12:35:17 +00:00
enableParallelBuilding = true;
doCheck = true;
2021-03-25 10:48:24 +00:00
checkInputs = [ python3 ];
2022-04-13 18:51:50 +00:00
2022-06-18 04:20:00 +00:00
CXXFLAGS = lib.optionalString stdenv.isDarwin "-D_BOOST_LGAMMA";
2022-04-13 18:51:50 +00:00
postPatch = ''
substituteInPlace stan/lib/stan_math/make/libraries \
--replace "/usr/bin/env bash" "bash"
patchShebangs .
'';
checkPhase = ''
./runCmdStanTests.py -j$NIX_BUILD_CORES src/test/interface
'';
2015-12-11 12:35:17 +00:00
installPhase = ''
mkdir -p $out/opt $out/bin
cp -r . $out/opt/cmdstan
ln -s $out/opt/cmdstan/bin/stanc $out/bin/stanc
ln -s $out/opt/cmdstan/bin/stansummary $out/bin/stansummary
cat > $out/bin/stan <<EOF
#!${runtimeShell}
2015-12-11 12:35:17 +00:00
make -C $out/opt/cmdstan "\$(realpath "\$1")"
EOF
chmod a+x $out/bin/stan
'';
2022-04-13 18:51:50 +00:00
# Hack to ensure that patchelf --shrink-rpath get rids of a $TMPDIR reference.
preFixup = "rm -rf $(pwd)";
2015-12-11 12:35:17 +00:00
meta = {
2022-06-18 04:20:00 +00:00
broken = stdenv.isLinux && stdenv.isAarch64;
2015-12-11 12:35:17 +00:00
description = "Command-line interface to Stan";
longDescription = ''
Stan is a probabilistic programming language implementing full Bayesian
statistical inference with MCMC sampling (NUTS, HMC), approximate Bayesian
inference with Variational inference (ADVI) and penalized maximum
likelihood estimation with Optimization (L-BFGS).
'';
homepage = "https://mc-stan.org/interfaces/cmdstan.html";
license = lib.licenses.bsd3;
platforms = lib.platforms.all;
2015-12-11 12:35:17 +00:00
};
}