bscpkgs/pkgs/ovni/default.nix
Rodrigo Arias Mallo 74e11db8b6 Only enable MPI in ovni on native builds
Tested with:

hut% nix build .#bsc-ci.all
hut% nix build .#pkgsCross.riscv64.ovni

Tested-by: Rodrigo Arias Mallo <rodrigo.arias@bsc.es>
Reviewed-by: Aleix Boné <aleix.boneribo@bsc.es>
2024-10-28 13:42:19 +01:00

61 lines
1.4 KiB
Nix

{
stdenv
, lib
, cmake
, mpi
, fetchFromGitHub
, useGit ? false
, gitBranch ? "master"
, gitUrl ? "ssh://git@bscpm03.bsc.es/rarias/ovni.git"
, gitCommit ? "7a33deffb7aaae70527125d48428f22169c9d39e"
, enableDebug ? false
# Only enable MPI if the build is native (fails on cross-compilation)
, useMpi ? (stdenv.buildPlatform.canExecute stdenv.hostPlatform)
}:
with lib;
let
release = rec {
version = "1.4.1";
src = fetchFromGitHub {
owner = "bsc-pm";
repo = "ovni";
rev = "${version}";
hash = "sha256-/vv7Yy6dzoxuHjMc0h/vFFwWzysPLXFZIN2rbLT/SC8=";
} // { shortRev = "7a33def"; };
};
git = rec {
version = src.shortRev;
src = builtins.fetchGit {
url = gitUrl;
ref = gitBranch;
rev = gitCommit;
};
};
source = if (useGit) then git else release;
in
stdenv.mkDerivation rec {
pname = "ovni";
inherit (source) src version;
dontStrip = true;
separateDebugInfo = true;
postPatch = ''
patchShebangs --build test/
'';
nativeBuildInputs = [ cmake ];
buildInputs = lib.optionals (useMpi) [ mpi ];
cmakeBuildType = if (enableDebug) then "Debug" else "Release";
cmakeFlags = [
"-DOVNI_GIT_COMMIT=${src.shortRev}"
] ++ lib.optionals (!useMpi) [ "-DUSE_MPI=OFF" ];
preCheck = ''
export CTEST_OUTPUT_ON_FAILURE=1
'';
doCheck = true;
checkTarget = "test";
hardeningDisable = [ "all" ];
}