From e179966d31ee9fb715a1966cdee8979ce36785bc Mon Sep 17 00:00:00 2001
From: Lars Bilke <lars.bilke@ufz.de>
Date: Tue, 14 Nov 2023 11:39:59 +0100
Subject: [PATCH] [guix] Moved packages into channel repo.

---
 .guix-channel                      |   5 -
 .guix/modules/ogs-dependencies.scm | 146 -----------------------------
 .guix/modules/ogs-package.scm      | 109 ---------------------
 guix.scm                           |   1 -
 scripts/ci/jobs/build-guix.yml     |  10 +-
 scripts/guix/channels.scm          |   8 +-
 6 files changed, 10 insertions(+), 269 deletions(-)
 delete mode 100644 .guix-channel
 delete mode 100644 .guix/modules/ogs-dependencies.scm
 delete mode 100644 .guix/modules/ogs-package.scm
 delete mode 120000 guix.scm

diff --git a/.guix-channel b/.guix-channel
deleted file mode 100644
index 292946e2518..00000000000
--- a/.guix-channel
+++ /dev/null
@@ -1,5 +0,0 @@
-;; This file lets us present this repo as a Guix channel.
-
-(channel
-  (version 0)
-  (directory ".guix/modules"))  ;look for package modules under .guix/modules/
\ No newline at end of file
diff --git a/.guix/modules/ogs-dependencies.scm b/.guix/modules/ogs-dependencies.scm
deleted file mode 100644
index a5dc6890ad8..00000000000
--- a/.guix/modules/ogs-dependencies.scm
+++ /dev/null
@@ -1,146 +0,0 @@
-(define-module (ogs-dependencies)
-  #:use-module (guix packages)
-  #:use-module (gnu packages image-processing)
-  #:use-module (guix git-download)
-  #:use-module (gnu packages python-xyz)
-  #:use-module ((guix licenses)
-                #:prefix license:)
-  #:use-module (guix build-system cmake)
-  #:use-module (guix build-system copy)
-  #:use-module (gnu packages xml))
-
-(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)
-        #~(append '("-DVTK_MODULE_ENABLE_VTK_IOParallelXML=YES"
-                    "-DVTK_MODULE_ENABLE_VTK_ParallelMPI=YES"
-                    "-DVTK_USE_MPI=ON")
-                  #$flags))))
-    (synopsis "VTK with OpenMPI support")))
-
-(define-public 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"))))))
-
-(define-public tetgen
-  (package
-    (name "tetgen")
-    (synopsis
-     "A Quality Tetrahedral Mesh Generator and a 3D Delaunay Triangulator")
-    (license license:agpl3)
-    (description
-     "TetGen is a program to generate tetrahedral meshes of any 3D polyhedral domains. TetGen generates exact constrained Delaunay tetrahedralizations, boundary conforming Delaunay meshes, and Voronoi partitions.")
-    (home-page "http://www.tetgen.org/")
-    (version "1.5.1-1")
-    (source (origin
-              (method git-fetch)
-              (uri (git-reference
-                    (url "https://github.com/ufz/tetgen")
-                    (commit version)))
-              (sha256
-               (base32
-                "1xp1qibm0q4z5qx0h178qpas3n7pqbladkxdalq9j4l98hdws46j"))))
-    (build-system cmake-build-system)
-    (arguments
-     `(#:tests? #f
-       #:configure-flags (list "-DCMAKE_POSITION_INDEPENDENT_CODE=ON")))))
-
-(define-public tclap
-  (package
-    (name "tclap")
-    (synopsis "Templatized Command Line Argument Parser")
-    (license license:expat)
-    (description
-     "This is a simple C++ library that facilitates parsing command line arguments in a type independent manner.")
-    (home-page "https://sourceforge.net/p/tclap/discussion/")
-    (version "1.2.4-1")
-    (source (origin
-              (method git-fetch)
-              (uri (git-reference
-                    (url "https://github.com/ufz/tclap")
-                    (commit version)))
-              (sha256
-               (base32
-                "0bijzfc9c8zny3m74y53i8m3f41kd8klcnmr9chy536syr9vdr5p"))))
-    (build-system cmake-build-system)
-    (arguments
-     `(#:tests? #f))))
-
-(define-public iphreeqc
-  (package
-    (name "iphreeqc")
-    (synopsis
-     "Modules Based on the Geochemical Model PHREEQC for use in scripting and programming languages")
-    (license license:public-domain)
-    (description "")
-    (home-page "https://www.usgs.gov/software/phreeqc-version-3")
-    (version "3.5.0-3")
-    (source (origin
-              (method git-fetch)
-              (uri (git-reference
-                    (url "https://github.com/ufz/iphreeqc")
-                    (commit version)))
-              (sha256
-               (base32
-                "12wiqyzpzx89k9c7q07w4ypnppvi6s88k6jjsnlnvaxfafyvrbw3"))))
-    (build-system cmake-build-system)
-    (arguments
-     `(#:tests? #f
-       #:configure-flags (list "-DCMAKE_POSITION_INDEPENDENT_CODE=ON")))))
-
-(define-public xmlpatch
-  (package
-    (name "xmlpatch")
-    (synopsis "An XML Patch library")
-    (license license:lgpl2.1)
-    (description "")
-    (home-page "https://xmlpatch.sourceforge.net")
-    (version "0.4.3")
-    (source (origin
-              (method git-fetch)
-              (uri (git-reference
-                    (url "https://gitlab.opengeosys.org/ogs/libs/xmlpatch")
-                    (commit (string-append "v" version))))
-              (sha256
-               (base32
-                "0872g9w1jd5r4c5a1s8ga4x1plg608b7rxyqjs6zv8ghjq9qlkvg"))))
-    (build-system cmake-build-system)
-    (inputs (list libxml2))
-    (arguments
-     `(#:tests? #f
-       #:configure-flags (list "-DBUILD_SHARED_LIBS=ON")))))
-
-(define-public exprtk
-  (package
-    (name "exprtk")
-    (home-page "https://www.partow.net/programming/exprtk/index.html")
-    (synopsis "C++ Mathematical Expression Parsing And Evaluation Library")
-    (description "")
-    (license license:expat)
-    (version "0.0.2")
-    (source (origin
-              (method git-fetch)
-              (uri (git-reference
-                    (url "https://github.com/ArashPartow/exprtk.git")
-                    (commit version)))
-              (sha256
-               (base32
-                "1w92qlfjpcan38d88fak3avq81lkcpai5mqpbvrsfv04mi5nfpk5"))))
-    (build-system copy-build-system)
-    (arguments
-     '(#:install-plan '(("exprtk.hpp" "include/"))))))
diff --git a/.guix/modules/ogs-package.scm b/.guix/modules/ogs-package.scm
deleted file mode 100644
index 86a393d00e9..00000000000
--- a/.guix/modules/ogs-package.scm
+++ /dev/null
@@ -1,109 +0,0 @@
-(define-module (ogs-package)
-  #:use-module (guix)
-  #:use-module (guix packages)
-  #:use-module (guix build-system cmake)
-  #: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 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)
-  #:use-module (ogs-dependencies))
-
-(define-public ogs
-  (package
-    (name "ogs")
-    (version "6.4.4")
-    (source (origin
-              (method git-fetch)
-              (uri (git-reference
-                    (url "https://gitlab.opengeosys.org/ogs/ogs.git")
-                    (commit "d4ca7e627f2fc012bfe434649b797e78e5c2a8f1")))
-              (file-name (git-file-name name version))
-              (sha256
-               (base32
-                "1f6mcbjx76irf1g0xkh6hgpv4qn2swbiyvlazvlrhjfyxb9bckq9"))))
-    (build-system cmake-build-system)
-    (arguments
-     `(#:build-type "Release"
-       #:configure-flags (list) ;empty list to be appended in inherited packages
-       #:cmake ,cmake)) ;for newer CMake version
-    (inputs (list boost
-                  eigen
-                  exprtk
-                  hdf5
-                  iphreeqc
-                  json-modern-cxx
-                  libxml2
-                  metis
-                  pybind11-2.10.4
-                  python
-                  range-v3
-                  spdlog
-                  tclap
-                  tetgen
-                  zlib
-                  vtk
-                  xmlpatch))
-    (native-inputs (list git ninja))
-    (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)")))
-
-;; return package
-ogs
diff --git a/guix.scm b/guix.scm
deleted file mode 120000
index 80998e585e9..00000000000
--- a/guix.scm
+++ /dev/null
@@ -1 +0,0 @@
-.guix/modules/ogs-package.scm
\ No newline at end of file
diff --git a/scripts/ci/jobs/build-guix.yml b/scripts/ci/jobs/build-guix.yml
index 46a65fb621f..04d7aaa5b4d 100644
--- a/scripts/ci/jobs/build-guix.yml
+++ b/scripts/ci/jobs/build-guix.yml
@@ -21,11 +21,11 @@ build guix:
     # SteadyStateDiffusion only!
     - |
       if [[ "$CI_MERGE_REQUEST_LABELS" =~ .*ci::guix\ only.* ]]; then
-        guix build --fallback -L $PWD/.guix/modules ogs
-        guix build --fallback -L $PWD/.guix/modules ogs-petsc
+        guix time-machine -C scripts/guix/channels.scm -- build ogs --with-source=ogs@6.4.4-testing=$PWD
+        guix time-machine -C scripts/guix/channels.scm -- build ogs-petsc --with-source=ogs-petsc@6.4.4-testing=$PWD
       else
-        guix build --fallback -L $PWD/.guix/modules ogs-ssd
-        guix build --fallback -L $PWD/.guix/modules ogs-petsc-ssd
+        guix time-machine -C scripts/guix/channels.scm -- build ogs-ssd --with-source=ogs-ssd@6.4.4-testing=$PWD
+        guix time-machine -C scripts/guix/channels.scm -- build ogs-petsc-ssd --with-source=ogs-petsc-ssd@6.4.4-testing=$PWD
       fi
 
 deploy guix container eve:
@@ -41,7 +41,7 @@ deploy guix container eve:
     - which guix
     - guix describe
     # All processes.
-    - image=$( guix pack --no-substitutes -L $PWD/.guix/modules -RR --format=squashfs bash ogs-petsc | tee | tail -1 )
+    - image=$( guix time-machine -C scripts/guix/channels.scm -- pack --no-substitutes -RR --format=squashfs bash ogs-petsc --with-source=ogs-petsc@6.4.4-testing=$PWD | tee | tail -1 )
     - echo "Image $image"
     - ssh sonjenk@frontend2.eve.ufz.de rm -f ${GUIX_PETSC_CONTAINER}
     - scp $image sonjenk@frontend2.eve.ufz.de:${GUIX_PETSC_CONTAINER}
diff --git a/scripts/guix/channels.scm b/scripts/guix/channels.scm
index c582cc07555..9855f7b64a5 100644
--- a/scripts/guix/channels.scm
+++ b/scripts/guix/channels.scm
@@ -1,12 +1,14 @@
 (list (channel
         (name 'guix-ogs)
-        (url "https://gitlab.opengeosys.org/ogs/inf/guix-ogs.git"))
+        (url "https://gitlab.opengeosys.org/ogs/inf/guix-ogs.git")
+        (branch "master")
+        (commit "f5f9b9c1a61527968c1848c3fbaef4a9bc44c891"))
       (channel
         (name 'guix)
         (url "https://git.savannah.gnu.org/git/guix.git")
-        (branch #f)
+        (branch "master")
         (commit
-          "8e2f32cee982d42a79e53fc1e9aa7b8ff0514714")
+          "0c1aa354048f82023e6d2043bfecc4fd58bc9b58")
         (introduction
           (make-channel-introduction
             "9edb3f66fd807b096b48283debdcddccfea34bad"
-- 
GitLab