2024-07-08 15:07:24 +05:00
|
|
|
{
|
2024-07-18 15:49:05 +05:00
|
|
|
bonLib,
|
2024-07-08 15:07:24 +05:00
|
|
|
stdenv,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
2024-07-24 13:18:58 +05:00
|
|
|
version ? "11.20240704",
|
|
|
|
sha256 ? "sha256-AUApKWg9YZ0Nmz8+pOcgu6RBPfGHk0X49lERFEiV0ZM=",
|
2024-07-08 15:07:24 +05:00
|
|
|
...
|
|
|
|
}: let
|
|
|
|
version' = lib.strings.splitString "." version;
|
|
|
|
major = lib.elemAt version' 0;
|
|
|
|
revision = lib.elemAt version' 1;
|
|
|
|
realname = "OpenFOAM";
|
|
|
|
in let
|
|
|
|
pkg = stdenv.mkDerivation {
|
2023-12-19 22:02:15 +05:00
|
|
|
pname = "openfoam";
|
|
|
|
inherit version major;
|
|
|
|
|
|
|
|
src = pkgs.fetchFromGitHub {
|
2024-07-08 15:07:24 +05:00
|
|
|
owner = realname;
|
|
|
|
repo = "${realname}-${major}";
|
|
|
|
rev = "${revision}";
|
|
|
|
sha256 = sha256;
|
2023-12-19 22:02:15 +05:00
|
|
|
};
|
|
|
|
|
2024-07-08 15:07:24 +05:00
|
|
|
nativeBuildInputs = with pkgs; [bash m4 flex bison];
|
2023-12-19 22:02:15 +05:00
|
|
|
|
2024-07-08 15:07:24 +05:00
|
|
|
buildInputs = with pkgs; [fftw mpi scotch boost cgal zlib];
|
2023-12-19 22:02:15 +05:00
|
|
|
|
|
|
|
postPatch = ''
|
2024-07-08 15:07:24 +05:00
|
|
|
substituteInPlace etc/bashrc \
|
|
|
|
--replace '[ "$BASH" -o "$ZSH_NAME" ] && \' '#' \
|
|
|
|
--replace 'export FOAM_INST_DIR=$(cd $(dirname ${"$"}{BASH_SOURCE:-$0})/../.. && pwd -P) || \' '#' \
|
|
|
|
--replace 'export FOAM_INST_DIR=$HOME/$WM_PROJECT' '# __inst_dir_placeholder__'
|
2023-12-19 22:02:15 +05:00
|
|
|
|
2024-07-08 15:07:24 +05:00
|
|
|
patchShebangs Allwmake
|
|
|
|
patchShebangs etc
|
|
|
|
patchShebangs wmake
|
|
|
|
patchShebangs applications
|
|
|
|
patchShebangs bin
|
2023-12-19 22:02:15 +05:00
|
|
|
'';
|
|
|
|
|
|
|
|
configurePhase = ''
|
2024-07-08 15:07:24 +05:00
|
|
|
export FOAM_INST_DIR=$NIX_BUILD_TOP/source
|
|
|
|
export WM_PROJECT_DIR=$FOAM_INST_DIR/${realname}-${major}
|
|
|
|
mkdir $WM_PROJECT_DIR
|
2023-12-19 22:02:15 +05:00
|
|
|
|
2024-07-08 15:07:24 +05:00
|
|
|
mv $(find $FOAM_INST_DIR/ -maxdepth 1 -not -path $WM_PROJECT_DIR -not -path $FOAM_INST_DIR/) \
|
|
|
|
$WM_PROJECT_DIR/
|
2023-12-19 22:02:15 +05:00
|
|
|
|
2024-07-08 15:07:24 +05:00
|
|
|
set +e
|
|
|
|
. $WM_PROJECT_DIR/etc/bashrc
|
|
|
|
set -e
|
2023-12-19 22:02:15 +05:00
|
|
|
'';
|
|
|
|
|
|
|
|
buildPhase = ''
|
2024-07-08 15:07:24 +05:00
|
|
|
sh $WM_PROJECT_DIR/Allwmake -j$CORES
|
|
|
|
wclean all
|
|
|
|
wmakeLnIncludeAll
|
2023-12-19 22:02:15 +05:00
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
2024-07-08 15:07:24 +05:00
|
|
|
mkdir -p $out/${realname}-${major}
|
2023-12-19 22:02:15 +05:00
|
|
|
|
2024-07-08 15:07:24 +05:00
|
|
|
substituteInPlace $WM_PROJECT_DIR/etc/bashrc \
|
|
|
|
--replace '# __inst_dir_placeholder__' "export FOAM_INST_DIR=$out"
|
2023-12-19 22:02:15 +05:00
|
|
|
|
2024-07-08 15:07:24 +05:00
|
|
|
cp -Ra $WM_PROJECT_DIR/* $out/${realname}-${major}
|
2023-12-19 22:02:15 +05:00
|
|
|
'';
|
|
|
|
|
2024-04-20 01:33:40 +05:00
|
|
|
passthru = {
|
2024-07-08 15:07:24 +05:00
|
|
|
shellHook = ''
|
|
|
|
. ${pkg}/${realname}-${major}/etc/bashrc
|
|
|
|
'';
|
2024-04-20 01:33:40 +05:00
|
|
|
};
|
|
|
|
|
2023-12-19 22:02:15 +05:00
|
|
|
meta = with pkgs.lib; {
|
2024-07-08 15:07:24 +05:00
|
|
|
homepage = "https://www.openfoam.org/";
|
|
|
|
description = "OpenFOAM is a free, open source CFD software released and developed by OpenFOAM Foundation";
|
|
|
|
license = licenses.gpl3;
|
|
|
|
platforms = platforms.linux;
|
2024-07-18 15:49:05 +05:00
|
|
|
maintainers = with bonLib.maintainers; [L-Nafaryus];
|
2024-07-08 15:07:24 +05:00
|
|
|
broken = pkgs.stdenv.isDarwin;
|
2023-12-19 22:02:15 +05:00
|
|
|
};
|
2024-07-08 15:07:24 +05:00
|
|
|
};
|
|
|
|
in
|
|
|
|
pkg
|