From 9711450d17987beab90fd8867b812fb62b7be515 Mon Sep 17 00:00:00 2001 From: gusgibbon Date: Thu, 25 Jul 2024 14:55:38 -0600 Subject: [PATCH] openfoam-org: init at 12 --- pkgs/by-name/op/openfoam-org/package.nix | 102 +++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 pkgs/by-name/op/openfoam-org/package.nix diff --git a/pkgs/by-name/op/openfoam-org/package.nix b/pkgs/by-name/op/openfoam-org/package.nix new file mode 100644 index 0000000000000..ae8e2086ce237 --- /dev/null +++ b/pkgs/by-name/op/openfoam-org/package.nix @@ -0,0 +1,102 @@ +{ + stdenv, + bash, + m4, + flex, + bison, + fftw, + gnumake, + mpi, + scotch, + boost, + cgal, + zlib, + fetchFromGitHub, + lib, + trilinos-mpi, + nix-update-script, +}: +stdenv.mkDerivation { + pname = "openfoam-org"; + version = "12"; + src = fetchFromGitHub { + owner = "OpenFOAM"; + repo = "OpenFOAM-12"; + rev = "858aab68ade2864dc8eb29b0a316d4c0fe6df1c9"; + hash = "sha256-1vFia30IzuSOLL5d3oNrRWSr8EUzwti9wOarUUa2SHM="; + }; + meta = with lib; { + description = "The open source CFD toolkit (openfoam.org)"; + homepage = "https://github.com/OpenFOAM/OpenFOAM-12"; + license = licenses.gpl3Only; + maintainers = with maintainers; [ gusgibbon ]; + platforms = with platforms; [ "x86_64-linux" ]; + }; + passthru.updateScript = nix-update-script { }; + nativeBuildInputs = [ + gnumake + bash + m4 + flex + bison + ]; + buildInputs = [ + fftw + mpi + mpi.dev + scotch + boost + cgal + zlib + trilinos-mpi + ]; + sourceRoot = "."; + patchPhase = '' + mkdir -p builduser/OpenFOAM + mkdir -p builduser/.OpenFOAM + export HOME=$(pwd)/builduser + mv source builduser/OpenFOAM/OpenFOAM-12 + mkdir -p builduser/OpenFOAM/OpenFOAM-12/paraviewout + + set +e + for f in \ + $HOME/OpenFOAM/OpenFOAM-12/wmake/scripts/* \ + $HOME/OpenFOAM/OpenFOAM-12/wmake/* + do + substituteInPlace $f --replace /bin/bash ${bash}/bin/bash + done + set -e + + rm $HOME/OpenFOAM/OpenFOAM-12/etc/config.sh/bash_completion + touch $HOME/OpenFOAM/OpenFOAM-12/etc/config.sh/bash_completion + + echo "set +e" | cat $HOME/OpenFOAM/OpenFOAM-12/etc/bashrc > tmp + rm $HOME/OpenFOAM/OpenFOAM-12/etc/bashrc + mv tmp $HOME/OpenFOAM/OpenFOAM-12/etc/bashrc + + echo "set +e" | cat $HOME/OpenFOAM/OpenFOAM-12/Allwmake > tmp + rm $HOME/OpenFOAM/OpenFOAM-12/Allwmake + mv tmp $HOME/OpenFOAM/OpenFOAM-12/Allwmake + + alias wmRefresh="placeholder" + chmod +x $HOME/OpenFOAM/OpenFOAM-12/Allwmake + chmod +x $HOME/OpenFOAM/OpenFOAM-12/applications/utilities/postProcessing/graphics/PVReaders/Allwmake + touch $HOME/.OpenFOAM/prefs.sh + ''; + configurePhase = '' + echo "export ZOLTAN_TYPE=system" >> $HOME/.OpenFOAM/prefs.sh + echo "export SCOTCH_TYPE=system" >> $HOME/.OpenFOAM/prefs.sh + ''; + buildPhase = '' + cd $HOME/OpenFOAM/OpenFOAM-12 + source ./etc/bashrc + ./Allwmake -j $CORES -q + ''; + installPhase = '' + mkdir -p $out/opt/OpenFOAM-12 + + cp -r bin $out/opt/OpenFOAM-12 + cp -r platforms $out/opt/OpenFOAM-12 + cp -r etc $out/opt/OpenFOAM-12 + ''; +}