76 lines
2.1 KiB
Markdown
76 lines
2.1 KiB
Markdown
# OpenFOAM nix shell environment
|
|
|
|
## Usage
|
|
|
|
With `direnv` installed and active (`eval $"(direnv hook bash)"`) the
|
|
environment loads itself when you enter this directory or any below it.
|
|
Simulations can be placed inside the `sims` directory. The `sims`
|
|
directory is ignored by git. If you change branches your simulations
|
|
should stay untouched. However it may lead to confusion if you have
|
|
simulation results from one OpenFOAM version and then change to another.
|
|
Clone this repository again for each OpenFOAM version you want to use to
|
|
not confuse yourself ;-)
|
|
|
|
## Requirements
|
|
|
|
### nix with flakes
|
|
On `nixos` flakes can be enabled by adding the following to your system
|
|
configuration:
|
|
|
|
``` nix
|
|
nix.settings.experimental-features = [ "nix-command" "flakes" ];
|
|
```
|
|
|
|
On other systems add the following to your `/etc/nix/nix.conf`:
|
|
|
|
``` conf
|
|
experimental-features = nix-command flakes
|
|
```
|
|
|
|
### direnv
|
|
|
|
After installing `direnv` it has to be loaded. Maybe add the hook to your
|
|
shellrc:
|
|
|
|
``` sh
|
|
echo 'eval "$(direnv hook bash)"' >> ~/.bashrc
|
|
```
|
|
|
|
See https://direnv.net/docs/hook.html for more information.
|
|
You'll need to `allow` the current directory:
|
|
|
|
``` sh
|
|
direnv allow
|
|
```
|
|
|
|
## Update nixpkgs
|
|
|
|
From within this directory run
|
|
|
|
``` sh
|
|
nix flake update
|
|
```
|
|
|
|
to pin to the latest `nixpkgs` version.
|
|
|
|
## Update OpenFOAM version
|
|
|
|
The OpenFOAM derivation is defined in `pkgs/openfoam/default.nix`. Edit the
|
|
variables in the `let` block at the top of the file and replace the
|
|
`"sha256-..."` string with an empty string. The first build will then fail
|
|
and give you the correct sha hash. Replace the empty string with it.
|
|
|
|
## Add different OpenFOAM release
|
|
|
|
There are branches for each OpenFOAM release. The main branch has always the
|
|
latest version. If you want to add a new one:
|
|
|
|
- create a new branch to hold the current version (e.g. openfoam-12)
|
|
- update the repository path in `pkgs/openfoam/default.nix` by editing the
|
|
parameters in the `let` block.
|
|
- adjust the `patches`, `postPatch`, `configurePhase`, `buildPhase` and
|
|
`installPhase` if required
|
|
|
|
Reevaluating `envrc` will build the new OpenFOAM (this may take a while (expect
|
|
up to 1h).
|