Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmdstan: add aarch64-darwin support #208132

Merged
merged 2 commits into from
Jan 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 23 additions & 22 deletions pkgs/development/compilers/cmdstan/default.nix
Original file line number Diff line number Diff line change
@@ -1,25 +1,18 @@
{ lib, stdenv, fetchurl, python3, runtimeShell }:
{ lib, stdenv, fetchFromGitHub, stanc, python3, buildPackages, runtimeShell }:

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
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;
version = "2.31.0";

src = fetchFromGitHub {
owner = "stan-dev";
repo = pname;
rev = "v${version}";
fetchSubmodules = true;
sha256 = "sha256-Uh/ZhEnbhQwC8xGFjDzH9No3VRgVbHYk2KoC+e3YhJw=";
};

nativeBuildInputs = [ stanc ];

buildFlags = [ "build" ];
enableParallelBuilding = true;
Expand All @@ -38,6 +31,13 @@ stdenv.mkDerivation rec {
src/test/interface/stansummary_test.cpp
'';

preConfigure = ''
mkdir -p bin
ln -s ${buildPackages.stanc}/bin/stanc bin/stanc
'';

makeFlags = lib.optional stdenv.isDarwin "arch=${stdenv.hostPlatform.darwinArch}";

checkPhase = ''
./runCmdStanTests.py -j$NIX_BUILD_CORES src/test/interface
'';
Expand All @@ -57,7 +57,7 @@ stdenv.mkDerivation rec {
# Hack to ensure that patchelf --shrink-rpath get rids of a $TMPDIR reference.
preFixup = "rm -rf stan";

meta = {
meta = with lib; {
description = "Command-line interface to Stan";
longDescription = ''
Stan is a probabilistic programming language implementing full Bayesian
Expand All @@ -66,7 +66,8 @@ stdenv.mkDerivation rec {
likelihood estimation with Optimization (L-BFGS).
'';
homepage = "https://mc-stan.org/interfaces/cmdstan.html";
license = lib.licenses.bsd3;
platforms = [ "aarch64-linux" "x86_64-darwin" "x86_64-linux" ];
license = licenses.bsd3;
maintainers = with maintainers; [ wegank ];
platforms = platforms.unix;
};
}
41 changes: 41 additions & 0 deletions pkgs/development/compilers/stanc/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{ lib
, fetchFromGitHub
, ocamlPackages
}:

ocamlPackages.buildDunePackage rec {
pname = "stanc";
version = "2.31.0";

minimalOCamlVersion = "4.12";

src = fetchFromGitHub {
owner = "stan-dev";
repo = "stanc3";
rev = "v${version}";
hash = "sha256-5GOyKVt3LHN1D6UysOZT8isVQLKexwEcK0rwI45dDcg=";
};

# Error: This expression has type [ `Use_Sys_unix ]
postPatch = ''
substituteInPlace test/integration/run_bin_on_args.ml \
--replace "if Sys.file_exists (to_windows path) then to_windows cmd else cmd" "cmd"
'';

buildInputs = with ocamlPackages; [
core_unix
menhir
menhirLib
ppx_deriving
fmt
yojson
];

meta = with lib; {
homepage = "https://github.com/stan-dev/stanc3";
description = "The Stan compiler and utilities";
license = licenses.bsd3;
maintainers = with maintainers; [ wegank ];
platforms = platforms.unix;
};
}
2 changes: 2 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15666,6 +15666,8 @@ with pkgs;

stalin = callPackage ../development/compilers/stalin { };

stanc = callPackage ../development/compilers/stanc { };

metaBuildEnv = callPackage ../development/compilers/meta-environment/meta-build-env { };

svd2rust = callPackage ../development/tools/rust/svd2rust { };
Expand Down