2020-07-27 17:55:56 +02:00
|
|
|
{
|
|
|
|
stdenv
|
|
|
|
, cc
|
|
|
|
, cflags ? null
|
|
|
|
, gitBranch
|
2020-08-04 18:38:33 +02:00
|
|
|
, blocksize ? 2048
|
|
|
|
, particles ? 16384
|
|
|
|
, timesteps ? 10
|
2020-07-27 17:55:56 +02:00
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "nbody";
|
|
|
|
|
|
|
|
src = builtins.fetchGit {
|
|
|
|
url = "ssh://git@bscpm02.bsc.es/rarias/nbody.git";
|
|
|
|
ref = gitBranch;
|
|
|
|
};
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
cc
|
|
|
|
];
|
|
|
|
|
|
|
|
preBuild = (if cflags != null then ''
|
2020-07-27 19:13:11 +02:00
|
|
|
makeFlagsArray+=(CFLAGS="${cflags}")
|
2020-07-27 17:55:56 +02:00
|
|
|
'' else "");
|
|
|
|
|
|
|
|
makeFlags = [
|
|
|
|
"CC=${cc.cc.CC}"
|
2020-08-04 18:38:33 +02:00
|
|
|
"BS=${toString blocksize}"
|
2020-07-27 17:55:56 +02:00
|
|
|
];
|
|
|
|
|
2020-08-10 14:13:28 +02:00
|
|
|
dontPatchShebangs = true;
|
|
|
|
|
2020-07-27 17:55:56 +02:00
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/bin
|
|
|
|
cp nbody $out/bin/
|
|
|
|
|
|
|
|
cat > $out/bin/run <<EOF
|
2020-08-10 14:13:28 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2020-08-04 18:38:33 +02:00
|
|
|
exec $out/bin/nbody -p ${toString particles} -t ${toString timesteps}
|
2020-07-27 17:55:56 +02:00
|
|
|
EOF
|
|
|
|
|
|
|
|
chmod +x $out/bin/run
|
|
|
|
'';
|
|
|
|
|
|
|
|
}
|