nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at 22.05 57 lines 1.8 kB view raw
1{ lib, stdenv, fetchurl, python3, runtimeShell }: 2 3stdenv.mkDerivation rec { 4 pname = "cmdstan"; 5 version = "2.29.2"; 6 7 # includes stanc binaries needed to build cmdstand 8 src = fetchurl { 9 url = "https://github.com/stan-dev/cmdstan/releases/download/v${version}/cmdstan-${version}.tar.gz"; 10 sha256 = "sha256-VntTH6c//fcGyqF+szROHftB6GmTyvi6QIdf+RAzUVM="; 11 }; 12 13 buildFlags = [ "build" ]; 14 enableParallelBuilding = true; 15 16 doCheck = true; 17 checkInputs = [ python3 ]; 18 19 postPatch = '' 20 substituteInPlace stan/lib/stan_math/make/libraries \ 21 --replace "/usr/bin/env bash" "bash" 22 patchShebangs . 23 ''; 24 25 checkPhase = '' 26 ./runCmdStanTests.py -j$NIX_BUILD_CORES src/test/interface 27 ''; 28 29 installPhase = '' 30 mkdir -p $out/opt $out/bin 31 cp -r . $out/opt/cmdstan 32 ln -s $out/opt/cmdstan/bin/stanc $out/bin/stanc 33 ln -s $out/opt/cmdstan/bin/stansummary $out/bin/stansummary 34 cat > $out/bin/stan <<EOF 35 #!${runtimeShell} 36 make -C $out/opt/cmdstan "\$(realpath "\$1")" 37 EOF 38 chmod a+x $out/bin/stan 39 ''; 40 41 # Hack to ensure that patchelf --shrink-rpath get rids of a $TMPDIR reference. 42 preFixup = "rm -rf $(pwd)"; 43 44 meta = { 45 broken = (stdenv.isLinux && stdenv.isAarch64) || stdenv.isDarwin; 46 description = "Command-line interface to Stan"; 47 longDescription = '' 48 Stan is a probabilistic programming language implementing full Bayesian 49 statistical inference with MCMC sampling (NUTS, HMC), approximate Bayesian 50 inference with Variational inference (ADVI) and penalized maximum 51 likelihood estimation with Optimization (L-BFGS). 52 ''; 53 homepage = "https://mc-stan.org/interfaces/cmdstan.html"; 54 license = lib.licenses.bsd3; 55 platforms = lib.platforms.all; 56 }; 57}