Initial commit
commit
df53449ed9
@ -0,0 +1,24 @@
|
|||||||
|
OpenFOAM.org
|
||||||
|
============
|
||||||
|
|
||||||
|
Para compilar e instalar este proyecto en el store:
|
||||||
|
|
||||||
|
```
|
||||||
|
nix-build
|
||||||
|
```
|
||||||
|
|
||||||
|
Para cargarlo en el entorno:
|
||||||
|
|
||||||
|
```
|
||||||
|
nix-env -i ./result
|
||||||
|
```
|
||||||
|
|
||||||
|
El entorno deja creados wrappers a todos los ejecutables de OpenFOAM.
|
||||||
|
Los wrappers se encargan de importar el `bashrc` previo a ejecutar los comandos.
|
||||||
|
Puede importarse el `bashrc` con:
|
||||||
|
|
||||||
|
```
|
||||||
|
source result/lib/OpenFOAM-20220727/etc/bashrc
|
||||||
|
```
|
||||||
|
|
||||||
|
y eso anulará los wrappers.
|
@ -0,0 +1,3 @@
|
|||||||
|
# default.nix
|
||||||
|
let pkgs = import <nixpkgs> {}; in
|
||||||
|
pkgs.callPackage ./openfoam10.nix {}
|
@ -0,0 +1,86 @@
|
|||||||
|
{ stdenv, lib, bashInteractive, fetchFromGitHub, makeWrapper, flex, bison
|
||||||
|
, zlib, boost, openmpi, readline, gperftools, cgal, metis, scotch, mpfr }:
|
||||||
|
|
||||||
|
|
||||||
|
stdenv.mkDerivation rec {
|
||||||
|
version = "20220727";
|
||||||
|
pname = "OpenFOAM-10";
|
||||||
|
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "OpenFOAM";
|
||||||
|
repo = pname;
|
||||||
|
name = "${pname}-${version}.zip";
|
||||||
|
rev = version;
|
||||||
|
sha256 = "2AeUaiOndZPsjedJC+zUDaL3Il9GNbS2eCEtdebaVag=";
|
||||||
|
};
|
||||||
|
|
||||||
|
# a lot of assumptions about being under a directory named OpenFOAM-${version}
|
||||||
|
postUnpack = ''
|
||||||
|
echo "resettting sourceRoot to ''${sourceRoot/-${version}.zip/}"
|
||||||
|
mv "$sourceRoot" "''${sourceRoot/-${version}.zip/}"
|
||||||
|
sourceRoot="''${sourceRoot/-${version}.zip/}"
|
||||||
|
'';
|
||||||
|
|
||||||
|
patchPhase = ''
|
||||||
|
patchShebangs .
|
||||||
|
'';
|
||||||
|
|
||||||
|
# one of the following would bake in the rpath, but sourcing etc/bashrc file updates LD_LIBRARY_PATH
|
||||||
|
# NIX_LDFLAGS="-rpath $out/platform/$WM_OPTIONS/lib $NIX_LDFLAGS"
|
||||||
|
# NIX_LDFLAGS="${NIX_LDFLAGS/"$out/lib$WM_ARCH_OPTION"/"$out/platform/$WM_OPTIONS/lib"}"
|
||||||
|
configurePhase = ''
|
||||||
|
sed -ie 's|/\.\./\.\.|/..|' etc/bashrc
|
||||||
|
sed -ie 's|FOAM_INST_DIR=$HOME/$WM_PROJECT.*|FOAM_INST_DIR='"$out"/lib/OpenFOAM-${version}'|' etc/bashrc
|
||||||
|
sed -ie 's|WM_PROJECT_DIR=$WM_PROJECT_INST_DIR/.*|WM_PROJECT_DIR=$FOAM_INST_DIR|' etc/bashrc
|
||||||
|
sed -ie 's|^\( *complete .\+\)$|\1 \|\| true|' etc/config.sh/bash_completion
|
||||||
|
sed -ie 's|^\( *unalias .\+ 2> */dev/null *\)$|\1 \|\| true|' etc/config.sh/aliases
|
||||||
|
sed -ie 's|METIS_ARCH_PATH=.*$|METIS_ARCH_PATH=${metis}|' etc/config.sh/metis
|
||||||
|
sed -ie 's|SCOTCH_ARCH_PATH=.*$|SCOTCH_ARCH_PATH=${scotch}|' etc/config.sh/scotch
|
||||||
|
sed -ie 's|gperftools_install=.*$|gperftools_install=${gperftools}|' etc/config.sh/gperftools
|
||||||
|
declare opts=$(shopt -p) output
|
||||||
|
set +o errexit
|
||||||
|
source "$PWD/etc/bashrc"
|
||||||
|
eval "$opts"
|
||||||
|
'';
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
export WM_NCOMPPROCS="''${NIX_BUILD_CORES}"
|
||||||
|
./Allwmake
|
||||||
|
'';
|
||||||
|
|
||||||
|
# stick etc, bin, and platforms under lib/OpenFOAM-${version}
|
||||||
|
# fill bin proper up with wrappers that source etc/bashrc for everything in platform/$WM_OPTIONS/bin
|
||||||
|
# add -mpi suffixed versions that calls proper mpirun for those with libPstream.so depencies too
|
||||||
|
installPhase = ''
|
||||||
|
echo "copying etc, bin, and platforms directories to $out/lib/OpenFOAM-${version}"
|
||||||
|
mkdir -p "$out/lib/OpenFOAM-${version}"
|
||||||
|
cp -at "$out/lib/OpenFOAM-${version}" etc bin platforms
|
||||||
|
echo "creating a bin of wrapped binaries from $out/lib/OpenFOAM-${version}/platforms/$WM_OPTIONS/bin"
|
||||||
|
for program in "$out/lib/OpenFOAM-${version}/platforms/$WM_OPTIONS/bin/"*; do
|
||||||
|
makeWrapper "$program" "$out/bin/''${program##*/}" \
|
||||||
|
--run "source \"$out/lib/OpenFOAM-${version}/etc/bashrc\" 2>/dev/null"
|
||||||
|
done
|
||||||
|
'';
|
||||||
|
|
||||||
|
buildInputs = [
|
||||||
|
makeWrapper
|
||||||
|
flex
|
||||||
|
bison
|
||||||
|
zlib
|
||||||
|
boost
|
||||||
|
openmpi
|
||||||
|
readline
|
||||||
|
gperftools
|
||||||
|
cgal
|
||||||
|
metis
|
||||||
|
scotch
|
||||||
|
mpfr
|
||||||
|
];
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
|
homepage = http://www.openfoam.com;
|
||||||
|
description = "Free open-source CFD software";
|
||||||
|
platforms = platforms.linux;
|
||||||
|
license = licenses.gpl3;
|
||||||
|
};
|
||||||
|
}
|
@ -0,0 +1,93 @@
|
|||||||
|
{ stdenv, lib, bashInteractive, fetchFromGitHub, makeWrapper, flex, bison
|
||||||
|
, zlib, boost, openmpi, readline, gperftools, cgal, metis, scotch, mpfr }:
|
||||||
|
|
||||||
|
|
||||||
|
stdenv.mkDerivation rec {
|
||||||
|
version = "20201114";
|
||||||
|
pname = "OpenFOAM-8";
|
||||||
|
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "OpenFOAM";
|
||||||
|
repo = pname;
|
||||||
|
name = "${pname}-${version}.zip";
|
||||||
|
rev = version;
|
||||||
|
sha256 = "1hl7zr405ifkppbm519yax5yqcm8zy1f98sfgy6zdnph2jx8fs34";
|
||||||
|
};
|
||||||
|
|
||||||
|
# a lot of assumptions about being under a directory named OpenFOAM-${version}
|
||||||
|
postUnpack = ''
|
||||||
|
echo "resettting sourceRoot to ''${sourceRoot/-${version}.zip/}"
|
||||||
|
mv "$sourceRoot" "''${sourceRoot/-${version}.zip/}"
|
||||||
|
sourceRoot="''${sourceRoot/-${version}.zip/}"
|
||||||
|
'';
|
||||||
|
|
||||||
|
|
||||||
|
# alternative to disabling exit on command failure with etc/bashrc could be
|
||||||
|
#
|
||||||
|
# sed -ie 's|^\( *unalias .\+ 2> */dev/null *\)$|\1 \|\| true|' etc/config.sh/aliases
|
||||||
|
# sed -ie 's|^\( *complete .\+\)$|\1 \|\| true|' etc/config.sh/bash_completion
|
||||||
|
patchPhase = ''
|
||||||
|
patchShebangs .
|
||||||
|
'';
|
||||||
|
|
||||||
|
# one of the following would bake in the rpath, but sourcing etc/bashrc file updates LD_LIBRARY_PATH
|
||||||
|
# NIX_LDFLAGS="-rpath $out/platform/$WM_OPTIONS/lib $NIX_LDFLAGS"
|
||||||
|
# NIX_LDFLAGS="${NIX_LDFLAGS/"$out/lib$WM_ARCH_OPTION"/"$out/platform/$WM_OPTIONS/lib"}"
|
||||||
|
configurePhase = ''
|
||||||
|
sed -ie 's|FOAM_INST_DIR=$HOME/$WM_PROJECT.*|FOAM_INST_DIR='"$out"/lib/OpenFOAM-${version}'|' etc/bashrc
|
||||||
|
sed -ie 's|METIS_ARCH_PATH=.*$|METIS_ARCH_PATH=${metis}|' etc/config.sh/metis
|
||||||
|
sed -ie 's|SCOTCH_ARCH_PATH=.*$|SCOTCH_ARCH_PATH=${scotch}|' etc/config.sh/scotch
|
||||||
|
sed -ie 's|gperftools_install=.*$|gperftools_install=${gperftools}|' etc/config.sh/gperftools
|
||||||
|
declare opts=$(shopt -p) output
|
||||||
|
set +o errexit
|
||||||
|
source "$PWD/etc/bashrc"
|
||||||
|
eval "$opts"
|
||||||
|
'';
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
export WM_NCOMPPROCS="''${NIX_BUILD_CORES}"
|
||||||
|
./Allwmake
|
||||||
|
'';
|
||||||
|
|
||||||
|
# stick etc, bin, and platforms under lib/OpenFOAM-${version}
|
||||||
|
# fill bin proper up with wrappers that source etc/bashrc for everything in platform/$WM_OPTIONS/bin
|
||||||
|
# add -mpi suffixed versions that calls proper mpirun for those with libPstream.so depencies too
|
||||||
|
installPhase = ''
|
||||||
|
echo "copying etc, bin, and platforms directories to $out/lib/OpenFOAM-${version}"
|
||||||
|
mkdir -p "$out/lib/OpenFOAM-${version}"
|
||||||
|
cp -at "$out/lib/OpenFOAM-${version}" etc bin platforms
|
||||||
|
echo "creating a bin of wrapped binaries from $out/lib/OpenFOAM-${version}/platforms/$WM_OPTIONS/bin"
|
||||||
|
for program in "$out/lib/OpenFOAM-${version}/platforms/$WM_OPTIONS/bin/"*; do
|
||||||
|
makeWrapper "$program" "$out/bin/''${program##*/}" \
|
||||||
|
--run "source \"$out/lib/OpenFOAM-${version}/etc/bashrc\""
|
||||||
|
if readelf -d "$program" | fgrep -q libPstream.so; then
|
||||||
|
makeWrapper "${openmpi}/bin/mpirun" "$out/bin/''${program##*/}-mpi" \
|
||||||
|
--run "[ -r processor0 ] || { echo \"Case is not currently decomposed, see decomposePar documentation\"; exit 1; }" \
|
||||||
|
--run "extraFlagsArray+=(-n \"\$(ls -d processor* | wc -l)\" \"$out/bin/''${program##*/}\" -parallel)" \
|
||||||
|
--run "source \"$out/lib/OpenFOAM-${version}/etc/bashrc\""
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
'';
|
||||||
|
|
||||||
|
buildInputs = [
|
||||||
|
makeWrapper
|
||||||
|
flex
|
||||||
|
bison
|
||||||
|
zlib
|
||||||
|
boost
|
||||||
|
openmpi
|
||||||
|
readline
|
||||||
|
gperftools
|
||||||
|
cgal
|
||||||
|
metis
|
||||||
|
scotch
|
||||||
|
mpfr
|
||||||
|
];
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
|
homepage = http://www.openfoam.com;
|
||||||
|
description = "Free open-source CFD software";
|
||||||
|
platforms = platforms.linux;
|
||||||
|
license = licenses.gpl3;
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue