Skip to content

Commit

Permalink
Merge branch 'guix-dev' into 'master'
Browse files Browse the repository at this point in the history
[guix] Dev setup

See merge request ogs/ogs!4685
  • Loading branch information
bilke committed Jul 25, 2023
2 parents d8e6e74 + 920a823 commit 11a9d3a
Show file tree
Hide file tree
Showing 8 changed files with 324 additions and 31 deletions.
5 changes: 5 additions & 0 deletions .guix-channel
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
;; This file lets us present this repo as a Guix channel.

(channel
(version 0)
(directory ".guix/modules")) ;look for package modules under .guix/modules/
218 changes: 218 additions & 0 deletions .guix/modules/ogs-package.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
;; This file defines a Guix package. It can be used to spawn an
;; interactive development environment:
;;
;; guix shell
;;
;; Or it can be used to build Guile from a checkout in an isolated
;; environment:
;;
;; guix build -f guix.scm
;;
;; Likewise, you may cross-compile it:
;;
;; guix build -f guix.scm --target=x86_64-w64-mingw32
;;
;; Or may want to build a variant:
;; guix build -L $PWD/.guix/modules ogs-petsc-ssd

(define-module (ogs-package)
#:use-module (guix)
#:use-module (guix packages)
#:use-module (guix build-system cmake)
#:use-module (guix download)
#:use-module (guix git-download)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (gnu packages algebra)
#:use-module (gnu packages boost)
#:use-module (gnu packages check)
#:use-module (gnu packages certs) ; TODO: cpm
#:use-module (gnu packages cmake)
#:use-module (gnu packages compression)
#:use-module (gnu packages cpp)
#:use-module (gnu packages image-processing)
#:use-module (gnu packages logging)
#:use-module (gnu packages maths)
#:use-module (gnu packages mpi)
#:use-module (gnu packages ninja)
#:use-module (gnu packages pretty-print)
#:use-module (gnu packages python-xyz)
#:use-module (gnu packages python)
#:use-module (gnu packages version-control)
#:use-module (gnu packages xml)
)

(define vcs-file?
;; Return true if the given file is under version control.
(or (git-predicate "../..") ; (current-source-directory)
(const #t))) ;not in a Git checkout

(define-public ogs
(package
(name "ogs")
(version "6.4.99-git")
(source (local-file "../.." "ogs-checkout"
#:recursive? #t
#:select? vcs-file?
))
(build-system cmake-build-system)
(arguments
`(#:build-type "Release"
#:configure-flags (list
; passing variables works like this
; ,(string-append "-DOGS_VERSION=" version)
; TODO: but it is not overwritten in sub-packages...
"-DGUIX_BUILD=ON"
"-DOGS_BUILD_TESTING=OFF"
"-DOGS_USE_EIGEN_UNSUPPORTED=OFF" ; Eigen 3.4.0
"-DOGS_INSTALL_DEPENDENCIES=OFF" ; handled by guix
"-DOGS_CPU_ARCHITECTURE=OFF" ; enable guix --tune
)
#:cmake ,cmake)) ;for newer CMake version
(inputs (list boost
eigen
fmt
googletest
hdf5
json-modern-cxx
libxml2
pybind11-2.10.4
python
range-v3
spdlog
zlib
vtk))
(native-inputs (list git ninja googletest nss-certs)) ; TODO: cpm
(synopsis "OpenGeoSys")
(description
"Simulation of thermo-hydro-mechanical-chemical (THMC) processes in porous and fractured media")
(home-page "https://www.opengeosys.org")
(properties '((tunable? . #t)))
(license license:bsd-3)))

(define-public ogs-ssd
(package
(inherit ogs)
(name "ogs-ssd")
(arguments
(substitute-keyword-arguments (package-arguments ogs)
((#:configure-flags flags)
`(cons* "-DOGS_BUILD_PROCESSES=SteadyStateDiffusion"
,flags))))
(synopsis "OGS with SteadyStateDiffusion only (for faster build testing)")))

(define-public ogs-petsc
(package
(inherit ogs)
(name "ogs-petsc")
(inputs (modify-inputs (package-inputs ogs)
(prepend openmpi petsc-openmpi)
(replace "vtk" vtk-openmpi)
(replace "hdf5" hdf5-parallel-openmpi)))
(arguments
(substitute-keyword-arguments (package-arguments ogs)
((#:configure-flags flags)
`(cons* "-DOGS_USE_PETSC=ON"
"-DCMAKE_C_COMPILER=mpicc"
"-DCMAKE_CXX_COMPILER=mpic++"
,flags))))
(synopsis "OGS with PETSc")))

(define-public ogs-petsc-ssd
(package
(inherit ogs-petsc)
(name "ogs-petsc-ssd")
(arguments
(substitute-keyword-arguments (package-arguments ogs-petsc)
((#:configure-flags flags)
`(cons* "-DOGS_BUILD_PROCESSES=SteadyStateDiffusion"
,flags))))
(synopsis "OGS with PETSc and SteadyStateDiffusion only (for faster build testing)")))

; #### Releases ####
(define-public ogs-6.4.4
(package
(inherit ogs)
(name "ogs")
(version "6.4.4")
(source (origin
(method git-fetch)
(uri (git-reference
(url "https://gitlab.opengeosys.org/ogs/ogs.git")
(commit "d4ca7e627f2fc012bfe434649b797e78e5c2a8f1")
(recursive? #t)))
(file-name (git-file-name name version))
(sha256
;; Update with `guix hash -rx .`, make sure to have submodules updated!
(base32
"1f6mcbjx76irf1g0xkh6hgpv4qn2swbiyvlazvlrhjfyxb9bckq9"))))
(synopsis "OGS 6.4.4 release")))

(define-public ogs-petsc-6.4.4
(package
(inherit ogs-petsc)
(name "ogs-petsc")
(version "6.4.4")
(source (origin
(method git-fetch)
(uri (git-reference
(url "https://gitlab.opengeosys.org/ogs/ogs.git")
(commit "d4ca7e627f2fc012bfe434649b797e78e5c2a8f1")
(recursive? #t)))
(file-name (git-file-name name version))
(sha256
;; Update with `guix hash -rx .`, make sure to have submodules updated!
(base32
"1f6mcbjx76irf1g0xkh6hgpv4qn2swbiyvlazvlrhjfyxb9bckq9"))))
(synopsis "OGS 6.4.4 with PETSc release")))

; #### Dependencies ####
(define-public vtk-openmpi
(package
(inherit vtk)
(name "vtk-openmpi")
(inputs (modify-inputs (package-inputs vtk)
(prepend hdf5-parallel-openmpi openmpi)))
(arguments
(substitute-keyword-arguments (package-arguments vtk)
((#:configure-flags flags)
`(cons* "-DVTK_MODULE_ENABLE_VTK_IOParallelXML=YES"
"-DVTK_MODULE_ENABLE_VTK_ParallelMPI=YES" "-DVTK_USE_MPI=ON"
,flags))))
(synopsis "VTK with OpenMPI support")))

(define pybind11-2.10.4
(package
(inherit pybind11)
(version "2.10.4")
(source (origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/pybind/pybind11")
(commit (string-append "v" version))))
(sha256
(base32
"0rbcfvl7y472sykzdq3vrkw83kar0lpzhk3wq9yj9cdydl8cpfcz"))))))
;; return package
ogs

;; TODO: add this to web page
; ## Using the ogs repo as a Guix channel (as a user of ogs)
;
; Add the following to `~/.config/guix/channels.scm`:
;
; ```scheme
; (append (list (channel
; (name 'ogs)
; (url "https://gitlab.opengeosys.org/ogs/ogs.git")
; (branch "master"))) %default-channels)
; ```
;
; Run `guix pull`.
;
; Then you can install the ogs package:
;
; ```bash
; guix install ogs@6.4.4
; # OR, e.g.
; guix install ogs-petsc@6.4.4
; ```
2 changes: 1 addition & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{
"name": "_binary_dir",
"hidden": true,
"binaryDir": "${sourceParentDir}/build/${presetName}"
"binaryDir": "${sourceParentDir}/build/$penv{CMAKE_PRESET_BUILD_DIR_PREFIX}${presetName}"
},
{
"name": "_release",
Expand Down
2 changes: 1 addition & 1 deletion ThirdParty/collection
Submodule collection updated from d1ab05 to c47c2e
1 change: 1 addition & 0 deletions guix.scm
3 changes: 2 additions & 1 deletion scripts/ci/jobs/build-guix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ build guix:
- when: manual
allow_failure: true
script:
- guix time-machine --channels=scripts/guix/channels.scm -- build ogs-ssd ogs-petsc-ssd --with-source=ogs-ssd@6.4.4=$PWD --with-source=ogs-petsc-ssd@6.4.4=$PWD
- guix time-machine --commit=v1.4.0 -- build -L $PWD/.guix/modules ogs-ssd
- guix time-machine --commit=v1.4.0 -- build -L $PWD/.guix/modules ogs-petsc-ssd
Loading

0 comments on commit 11a9d3a

Please sign in to comment.