diff --git a/gnu/packages/simulation.scm b/gnu/packages/simulation.scm
index f01044e76a..6b61783c2c 100644
--- a/gnu/packages/simulation.scm
+++ b/gnu/packages/simulation.scm
@@ -401,15 +401,166 @@ (define-public openfoam-org
           (add-after 'add-symbolic-link 'wrap
             (lambda* (#:key python inputs outputs #:allow-other-keys)
               (let* ((bin (string-append #$output "/bin"))
-                     (openfoam (string-append #$output
-                                              "/share/OpenFOAM-"
-                                              #$(package-version this-package))))
+                     (openfoam-version #$(package-version this-package))
+                     (openfoam-root (string-append #$output
+                                                   "/share/OpenFOAM-"
+                                                   openfoam-version))
+                     (openmpi-version #$(package-version openmpi))
+                     (paraview-version #$(package-version paraview))
+                     (paraview-version-major+minor
+                      #$(version-major+minor (package-version paraview))))
                 (for-each
                  (lambda (program)
                    (unless (member program
                                    '("." ".."))
+                     ;; wrap the programs with all the variables created by sourcing
+                     ;; etc/bashrc
                      (wrap-program (string-append bin "/" program)
-                       `("WM_PROJECT_DIR" ":" prefix (,openfoam)))))
+                       `("WM_PROJECT_INST_DIR" = (,openfoam-root))
+                       `("WM_PROJECT_DIR" = (,openfoam-root))
+                       '("WM_PROJECT" = ("OpenFOAM"))
+                       `("WM_PROJECT_VERSION" = (,openfoam-version))
+                       '("WM_COMPILER_TYPE" = ("system"))
+                       '("WM_COMPILER" = ("Gcc"))
+                       '("WM_ARCH_OPTION" = ("64"))
+                       '("WM_PRECISION_OPTION" = ("DP"))
+                       '("WM_LABEL_SIZE" = ("32"))
+                       '("WM_COMPILE_OPTION" = ("Opt"))
+                       '("WM_MPLIB" = ("OPENMPI"))
+                       '("WM_OSTYPE" = ("POSIX"))
+                       '("WM_OPTIONS" = ("linux64GccDPInt32Opt"))
+                       `("WM_PROJECT_USER_DIR" = (,(string-append
+                                                    "$HOME/OpenFOAM/$USER-"
+                                                    openfoam-version)))
+                       `("WM_THIRD_PARTY_DIR" = (,(string-append
+                                                   openfoam-root
+                                                   "/ThirdParty-"
+                                                   openfoam-version)))
+                       '("WM_LABEL_OPTION" = ("Int32"))
+                       '("WM_LINK_LANGUAGE" = ("c++"))
+                       '("WM_COMPILER_LIB_ARCH" = ("64"))
+                       `("WM_DIR" = (,(string-append openfoam-root "/wmake")))
+                       '("WM_LDFLAGS" = ("-m64"))
+                       '("WM_CC" = ("gcc"))
+                       '("WM_CFLAGS" = ("-m64 -fPIC"))
+                       '("WM_CXX" = ("g++"))
+                       '("WM_CXXFLAGS" = ("-m64 -fPIC -std=c++0x"))
+                       
+                       `("FOAM_INST_DIR" = (,openfoam-root))
+                       `("FOAM_APP" = (,(string-append openfoam-root
+                                                       "/applications")))
+                       `("FOAM_SRC" = (,(string-append openfoam-root "/src")))
+                       `("FOAM_ETC" = (,(string-append openfoam-root "/etc")))
+                       `("FOAM_TUTORIALS" = (,(string-append openfoam-root
+                                                             "/tutorials")))
+                       `("FOAM_UTILITIES" = (,(string-append
+                                               openfoam-root
+                                               "/applications/utilities")))
+                       `("FOAM_SOLVERS" = (,(string-append
+                                             openfoam-root
+                                             "/applications/solvers")))
+                       `("FOAM_MPI" = (,(string-append "openmpi-"
+                                                       openmpi-version)))
+                       `("FOAM_RUN" = (,(string-append "$HOME/OpenFOAM/$USER-"
+                                                       openfoam-version "/run")))
+                       `("FOAM_EXT_LIBBIN" = (,(string-append
+                                                openfoam-root
+                                                "/ThirdParty-"
+                                                openfoam-version
+                                                "/platforms/linux64GccDPInt32/lib")))
+                       `("FOAM_APPBIN" = (,(string-append
+                                            openfoam-root
+                                            "/platforms/linux64GccDPInt32Opt/bin")))
+                       `("FOAM_JOB_DIR" = (,(string-append openfoam-root
+                                                           "/jobControl")))
+                       `("FOAM_LIBBIN" = (,(string-append
+                                            openfoam-root
+                                            "/platforms/linux64GccDPInt32Opt/lib")))
+                       `("FOAM_SITE_LIBBIN" = (,(string-append
+                                                 openfoam-root
+                                                 "/site/"
+                                                 openfoam-version
+                                                 "/platforms/linux64GccDPInt32Opt/lib")))
+                       `("FOAM_SITE_APPBIN" = (,(string-append
+                                                 openfoam-root
+                                                 "/site/"
+                                                 openfoam-version
+                                                 "/platforms/linux64GccDPInt32Opt/bin")))
+                       `("FOAM_USER_LIBBIN" = (,(string-append
+                                                 "$HOME/OpenFOAM/$USER-"
+                                                 openfoam-version
+                                                 "/platforms/linux64GccDPInt32Opt/lib")))
+                       `("FOAM_USER_APPBIN" = (,(string-append
+                                                 "$HOME/OpenFOAM/$USER-"
+                                                 openfoam-version
+                                                 "/platforms/linux64GccDPInt32Opt/bin")))
+                       `("FOAM_MODULES" = (,(string-append openfoam-root
+                                                           "/applications/modules")))
+                       '("FOAM_SIGFPE" = (""))
+                       '("FOAM_SETTINGS" = (""))
+
+                       `("ParaView_INCLUDE_DIR" = (,(string-append #$paraview
+                                                                   "/include/paraview-"
+                                                                   paraview-version-major+minor)))
+                       '("ParaView_GL" = ("mesa"))
+                       `("ParaView_VERSION" = (,paraview-version))
+                       `("ParaView_MAJOR" = (,paraview-version-major+minor))
+                       `("ParaView_DIR" = (,#$paraview))
+                       `("PV_PLUGIN_PATH" = (,(string-append
+                                               openfoam-root
+                                               "/platforms/linux64GccDPInt32Opt/lib/paraview-"
+                                               paraview-version-major+minor)))
+
+                       `("MPI_ARCH_PATH" = (,#$openmpi))
+                       `("OPAL_PREFIX" = (,#$openmpi))
+                       '("MPI_BUFFER_SIZE" = ("20000000"))
+                       
+                       `("LD_LIBRARY_PATH" prefix
+                         (,(string-append openfoam-root "/ThirdParty-"
+                                          openfoam-version
+                                          "/platforms/linux64Gcc/gperftools-svn/lib")
+                          ,(string-append #$paraview "/lib")
+                          ,(string-append openfoam-root
+                                          "/platforms/linux64GccDPInt32Opt/lib/openmpi-"
+                                          openmpi-version)
+                          ,(string-append openfoam-root "/ThirdParty-"
+                                          openfoam-version
+                                          "/platforms/linux64GccDPInt32/lib/openmpi-"
+                                          openmpi-version)
+                          ,(string-append #$openmpi "/lib")
+                          ,(string-append #$openmpi "/lib64")
+                          ,(string-append "$HOME/OpenFOAM/$USER-"
+                                          openfoam-version
+                                          "/platforms/linux64GccDPInt32Opt/lib")
+                          ,(string-append openfoam-root "/site/"
+                                          openfoam-version
+                                          "/platforms/linux64GccDPInt32Opt/lib")
+                          ,(string-append openfoam-root
+                                          "/platforms/linux64GccDPInt32Opt/lib")
+                          ,(string-append openfoam-root "/ThirdParty-"
+                                          openfoam-version
+                                          "/platforms/linux64GccDPInt32/lib")
+                          ,(string-append openfoam-root
+                                          "/platforms/linux64GccDPInt32Opt/lib/dummy")))
+                       `("PATH" prefix
+                         (,(string-append openfoam-root "/ThirdParty-"
+                                          openfoam-version
+                                          "/platforms/linux64Gcc/gperftools-svn/bin")
+                          ,(string-append #$paraview "/bin")
+                          ,(string-append openfoam-root "/ThirdParty-"
+                                          openfoam-version
+                                          "/platforms/linux64Gcc/cmake-*/bin")
+                          ,(string-append #$openmpi "/bin")
+                          ,(string-append openfoam-root "/bin")
+                          ,(string-append openfoam-root "/wmake")
+                          ,(string-append "$HOME/OpenFOAM/$USER-"
+                                          openfoam-version
+                                          "/platforms/linux64GccDPInt32Opt/bin")
+                          ,(string-append openfoam-root "/site/"
+                                          openfoam-version
+                                          "/platforms/linux64GccDPInt32Opt/bin")
+                          ,(string-append openfoam-root
+                                          "/platforms/linux64GccDPInt32Opt/bin"))))))
                  (scandir bin))))))))
     ;; Note:
     ;; Tutorial files are installed read-only in /gnu/store.
