Subject: [bug#70056] [RFC PATCH] draft: gnu: Add mfem.

From: "Paul A. Patience" <[email-masked]>
Date: Thu, 28 Mar 2024 14:17:39 +0000

* gnu/packages/maths.scm (mfem): New variable.

Change-Id: Ida81f2b081a016e91426b68437909653020976f5
---
Hi,

I'm trying to package MFEM, but I get the following error while building:

--8<---------------cut here---------------start------------->8---
The following derivations will be built:
  /gnu/store/ibv1qjm24b2z4qsfhsw7q4izalcbb7rd-mfem-4.6.drv
  /gnu/store/l0df6d28w16dhnnpcr1qg26xvpmyrkqa-mfem-4.6-checkout.drv
building /gnu/store/l0df6d28w16dhnnpcr1qg26xvpmyrkqa-mfem-4.6-checkout.drv...
Initialized empty Git repository in /gnu/store/dc5fx7xfg67fsvl5brdxnbgkirirqxd0-mfem-4.6-checkout/.git/
>From https://github.com/mfem/mfem
 * tag               v4.6       -> FETCH_HEAD
warning: unable to access '//.config/git/ignore': Permission denied
warning: unable to access '//.config/git/attributes': Permission denied
warning: unable to access '//.config/git/ignore': Permission denied
Note: switching to 'FETCH_HEAD'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 69fbae7 Merge pull request #3841 from mfem/mfem-4.6-dev
suspicious ownership or permission on `/gnu/store/dc5fx7xfg67fsvl5brdxnbgkirirqxd0-mfem-4.6-checkout'; rejecting this build output
build of /gnu/store/l0df6d28w16dhnnpcr1qg26xvpmyrkqa-mfem-4.6-checkout.drv failed
View build log at '/var/log/guix/drvs/l0/df6d28w16dhnnpcr1qg26xvpmyrkqa-mfem-4.6-checkout.drv.gz'.
cannot build derivation `/gnu/store/ibv1qjm24b2z4qsfhsw7q4izalcbb7rd-mfem-4.6.drv': 1 dependencies couldn't be built
guix build: error: build of `/gnu/store/ibv1qjm24b2z4qsfhsw7q4izalcbb7rd-mfem-4.6.drv' failed
--8<---------------cut here---------------end--------------->8---

Basically it complains of suspicious ownership or permission.
I looked at the permissions of the contents of the repository when cloning it
manually, and nothing seems to be world-writable, as
nix/libstore/build.cc:2373 seems to be trying to protect against.

Regarding the Git warning at the top, I looked in the repository for any
references to Git attributes and ignore files, but did not find any.
I suspect it is looking for the .config directory in $HOME, but the variable
is unset, of course.

What's more, I tried with url-fetch, and it also results in suspicious
ownership or permission.

I'm at a loss as to what to do.

Can someone give me a hand?

Thanks,
Paul

 gnu/packages/maths.scm | 48 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm
index 1b4d325649..5e81225947 100644
--- a/gnu/packages/maths.scm
+++ b/gnu/packages/maths.scm
@@ -151,6 +151,7 @@ (define-module (gnu packages maths)
   #:use-module (gnu packages xorg)
   #:use-module (gnu packages gl)
   #:use-module (gnu packages imagemagick)
+  #:use-module (gnu packages libunwind)
   #:use-module (gnu packages m4)
   #:use-module (gnu packages mpi)
   #:use-module (gnu packages multiprecision)
@@ -6890,6 +6891,53 @@ (define-public dealii-openmpi
             (delete 'unset-cpath)))))
     (synopsis "Finite element library (with MPI support)")))
 
+(define-public mfem
+  (package
+    (name "mfem")
+    (version "4.6")
+    (source
+     (origin
+       ;; (method url-fetch)
+       ;; (uri (string-append "https://github.com/mfem/mfem/archive/refs/tags/v"
+       ;;                     version ".tar.gz"))
+       ;; (file-name (string-append name "-" version ".tar.gz"))
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/mfem/mfem")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "0m57j5kd7glc8lfp5bdmmx4az4fs6lkqjwd970w4fx8gylxff3n9"))))
+    (build-system cmake-build-system)
+    (native-inputs
+     (list graphviz doxygen perl))      ; documentation
+    (inputs
+     (list gfortran
+           gnutls
+           lapack
+           libunwind
+           metis
+           mpfr
+           netcdf
+           suitesparse-amd
+           suitesparse-btf
+           suitesparse-camd
+           suitesparse-ccolamd
+           suitesparse-cholmod
+           suitesparse-colamd
+           suitesparse-config
+           suitesparse-klu
+           suitesparse-umfpack
+           sundials
+           zlib))
+    (home-page "https://mfem.org/")
+    (synopsis "Finite element library")
+    (description "MFEM is a modular parallel C++ library for finite element
+methods.  Its goal is to enable high-performance scalable finite element
+discretization research and application development on a wide variety of
+platforms, ranging from laptops to supercomputers.")
+    (license license:bsd-3)))
+
 (define-public flann
   (package
     (name "flann")

base-commit: fb9549164520ad993c2fbbaedc899844d57baabc
-- 
2.41.0