Skip to content

Commit

Permalink
cmdstan: unbreak on aarch64-linux
Browse files Browse the repository at this point in the history
  • Loading branch information
wegank committed Dec 8, 2022
1 parent 8cdc50c commit 79a7bab
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions pkgs/development/compilers/cmdstan/default.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
{ lib, stdenv, fetchurl, python3, runtimeShell }:

stdenv.mkDerivation rec {
pname = "cmdstan";
version = "2.31.0";

let
# FIXME: remove conditional on future release
version = if stdenv.isx86_64 then "2.31.0" else "2.30.1";
# includes stanc binaries needed to build cmdstand
src = fetchurl {
url = "https://github.com/stan-dev/cmdstan/releases/download/v${version}/cmdstan-${version}.tar.gz";
sha256 = "sha256-BMqRRWIC/Z7It2qkESJd9L3ycyxvA6NHiWbAvzVMzIQ=";
srcs = rec {
aarch64-linux = fetchurl {
url = "https://github.com/stan-dev/cmdstan/releases/download/v${version}/cmdstan-${version}-linux-arm64.tar.gz";
sha256 = "sha256-oj/7JHT4LZcRAHiA2KbM6pZbOe6C98Ff//cNsG9DIm8=";
};
x86_64-darwin = fetchurl {
url = "https://github.com/stan-dev/cmdstan/releases/download/v${version}/cmdstan-${version}.tar.gz";
sha256 = "sha256-BMqRRWIC/Z7It2qkESJd9L3ycyxvA6NHiWbAvzVMzIQ=";
};
x86_64-linux = x86_64-darwin;
};
src = srcs.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
in
stdenv.mkDerivation rec {
pname = "cmdstan";
inherit version src;

buildFlags = [ "build" ];
enableParallelBuilding = true;
Expand All @@ -22,6 +33,9 @@ stdenv.mkDerivation rec {
substituteInPlace stan/lib/stan_math/make/libraries \
--replace "/usr/bin/env bash" "bash"
patchShebangs .
'' + lib.optionalString stdenv.isAarch64 ''
sed -z -i "s/TEST(CommandStansummary, check_console_output).*TEST(CommandStansummary, check_csv_output)/TEST(CommandStansummary, check_csv_output)/" \
src/test/interface/stansummary_test.cpp
'';

checkPhase = ''
Expand All @@ -41,10 +55,9 @@ stdenv.mkDerivation rec {
'';

# Hack to ensure that patchelf --shrink-rpath get rids of a $TMPDIR reference.
preFixup = "rm -rf $(pwd)";
preFixup = "rm -rf stan";

meta = {
broken = stdenv.isLinux && stdenv.isAarch64;
description = "Command-line interface to Stan";
longDescription = ''
Stan is a probabilistic programming language implementing full Bayesian
Expand All @@ -54,6 +67,6 @@ stdenv.mkDerivation rec {
'';
homepage = "https://mc-stan.org/interfaces/cmdstan.html";
license = lib.licenses.bsd3;
platforms = lib.platforms.all;
platforms = [ "aarch64-linux" "x86_64-darwin" "x86_64-linux" ];
};
}

0 comments on commit 79a7bab

Please sign in to comment.