bscpkgs/garlic/apps/nbody/default.nix
2021-04-21 18:23:27 +02:00

59 lines
1.0 KiB
Nix

{
stdenv
, cc
, mpi ? null
, tampi ? null
, mcxx ? null
, cflags ? null
, gitBranch ? "garlic/seq"
, gitCommit ? null
, blocksize ? 2048
, garlicTools
}:
assert !(tampi != null && mcxx == null);
with stdenv.lib;
let
gitSource = garlicTools.fetchGarlicApp {
appName = "nbody";
inherit gitCommit gitBranch;
gitTable = import ./git-table.nix;
};
in
stdenv.mkDerivation rec {
name = "nbody";
inherit (gitSource) src gitBranch gitCommit;
programPath = "/bin/nbody";
buildInputs = [
cc
]
++ optional (mpi != null) mpi
++ optional (tampi != null) tampi
++ optional (mcxx != null) mcxx;
preBuild = (if cflags != null then ''
makeFlagsArray+=(CFLAGS="${cflags}")
'' else "");
makeFlags = [
"CC=${cc.CC}"
"BS=${toString blocksize}"
]
++ optional (tampi != null) "TAMPI_HOME=${tampi}";
dontPatchShebangs = true;
installPhase = ''
echo ${tampi}
mkdir -p $out/bin
cp nbody* $out/bin/${name}
'';
hardeningDisable = [ "all" ];
}