migration: packages: openfoam

This commit is contained in:
L-Nafaryus 2023-12-19 22:02:15 +05:00
parent 52fba221e8
commit b356074430
No known key found for this signature in database
GPG Key ID: C76D8DCD2727DBB7
4 changed files with 95 additions and 0 deletions

View File

@ -1,3 +1,5 @@
# self.devShells.${system}
#
{ self, nixpkgs, ... }:
let
forAllSystems = nixpkgs.lib.genAttrs [ "x86_64-linux" ];
@ -10,4 +12,6 @@ in forAllSystems(system: let
in {
netgen = import ./netgen.nix { inherit pkgs bpkgs; };
openfoam = import ./openfoam.nix { inherit pkgs bpkgs; };
})

11
devShells/openfoam.nix Normal file
View File

@ -0,0 +1,11 @@
{ pkgs, bpkgs, ... }:
pkgs.mkShellNoCC {
packages = with pkgs; [
bpkgs.openfoam
mpi
];
shellHook = ''
. ${bpkgs.openfoam}/OpenFOAM-${bpkgs.openfoam.major}/etc/bashrc
'';
}

View File

@ -1,3 +1,5 @@
# self.packages.${system}
#
{ self, nixpkgs, ... }:
let
forAllSystems = nixpkgs.lib.genAttrs [ "x86_64-linux" ];
@ -10,4 +12,6 @@ in forAllSystems(system: let pkgs = nixpkgsFor.${system}; in {
netgen = pkgs.callPackage ./netgen {};
dearpygui = pkgs.callPackage ./dearpygui {};
openfoam = pkgs.callPackage ./openfoam {};
})

View File

@ -0,0 +1,76 @@
{
stdenv, lib, pkgs,
version ? "11.20230907",
sha256 ? "sha256-oT9NkQR/KGQYPX5gNuebMZFz+hxG5vp4fownQMkX5r0=", ...
}:
let
version' = lib.strings.splitString "." version;
major = lib.elemAt version' 0;
revision = lib.elemAt version' 1;
realname = "OpenFOAM";
in stdenv.mkDerivation {
pname = "openfoam";
inherit version major;
src = pkgs.fetchFromGitHub {
owner = realname;
repo = "${realname}-${major}";
rev = "${revision}";
sha256 = sha256;
};
nativeBuildInputs = with pkgs; [ bash m4 flex bison ];
buildInputs = with pkgs; [ fftw mpi scotch boost cgal zlib ];
postPatch = ''
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__'
patchShebangs Allwmake
patchShebangs etc
patchShebangs wmake
patchShebangs applications
patchShebangs bin
'';
configurePhase = ''
export FOAM_INST_DIR=$NIX_BUILD_TOP/source
export WM_PROJECT_DIR=$FOAM_INST_DIR/${realname}-${major}
mkdir $WM_PROJECT_DIR
mv $(find $FOAM_INST_DIR/ -maxdepth 1 -not -path $WM_PROJECT_DIR -not -path $FOAM_INST_DIR/) \
$WM_PROJECT_DIR/
set +e
. $WM_PROJECT_DIR/etc/bashrc
set -e
'';
buildPhase = ''
sh $WM_PROJECT_DIR/Allwmake -j$CORES
wclean all
wmakeLnIncludeAll
'';
installPhase = ''
mkdir -p $out/${realname}-${major}
substituteInPlace $WM_PROJECT_DIR/etc/bashrc \
--replace '# __inst_dir_placeholder__' "export FOAM_INST_DIR=$out"
cp -Ra $WM_PROJECT_DIR/* $out/${realname}-${major}
'';
meta = with pkgs.lib; {
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;
maintainers = [];
broken = pkgs.stdenv.isDarwin;
};
}