Subject: [PATCH v4] gnu: slurm: Enable REST API.

From: Arun Isaac <[email-masked]>
Date: Fri, 25 Oct 2024 16:24:30 +0100

Rename slurm and slurm-* to slurm-minimal and slurm-minimal-*. Add new slurm
packages that inherit from slurm-minimal and have the REST API enabled.

* gnu/packages/parallel.scm (make-slurm): New function.
(slurm-minimal, slurm-minimal-23.02, slurm-minimal-22.05, slurm-minimal-21.08,
slurm-minimal-20.11, slurm-minimal-20.02, slurm-minimal-19.05,
slurm-minimal-18.08): New variables.
(slurm, slurm-23.02, slurm-22.05, slurm-21.08, slurm-20.11, slurm-20.02,
slurm-19.05, slurm-18.08): Inherit from slurm-minimal, slurm-minimal-23.02,
slurm-minimal-22.05, slurm-minimal-21.08, slurm-minimal-20.11,
slurm-minimal-20.02, slurm-minimal-19.05 and slurm-minimal-18.08 respectively.

Change-Id: I6410ac385d8876f4b6a908ddb1272172475a87bb
---
 gnu/packages/parallel.scm | 98 ++++++++++++++++++++++++++++-----------
 1 file changed, 72 insertions(+), 26 deletions(-)

diff --git a/gnu/packages/parallel.scm b/gnu/packages/parallel.scm
index 89d82fb8da..66997951c3 100644
--- a/gnu/packages/parallel.scm
+++ b/gnu/packages/parallel.scm
@@ -15,6 +15,7 @@
 ;;; Copyright © 2024 Zheng Junjie <[email-masked]>
 ;;; Copyright © 2024 David Elsing <[email-masked]>
 ;;; Copyright © 2024 Romain Garbage <[email-masked]>
+;;; Copyright © 2024 Arun Isaac <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -49,14 +50,17 @@ (define-module (gnu packages parallel)
   #:use-module (gnu packages base)
   #:use-module (gnu packages bash)
   #:use-module (gnu packages check)
+  #:use-module (gnu packages databases)
   #:use-module (gnu packages documentation)
   #:use-module (gnu packages flex)
   #:use-module (gnu packages freeipmi)
   #:use-module (gnu packages gcc)
+  #:use-module (gnu packages glib)
   #:use-module (gnu packages libevent)
   #:use-module (gnu packages linux)
   #:use-module (gnu packages maths)
   #:use-module (gnu packages mpi)
+  #:use-module (gnu packages networking)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages python)
@@ -64,6 +68,7 @@ (define-module (gnu packages parallel)
   #:use-module (gnu packages python-science)
   #:use-module (gnu packages python-xyz)
   #:use-module (gnu packages readline)
+  #:use-module (gnu packages serialization)
   #:use-module (gnu packages tcl)
   #:use-module (gnu packages tls)
   #:use-module (gnu packages web))
@@ -190,9 +195,9 @@ (define-public xjobs
 when jobs finish.")
     (license license:gpl2+)))
 
-(define-public slurm
+(define-public slurm-minimal
   (package
-    (name "slurm")
+    (name "slurm-minimal")
     (version "23.11.10")
     (source (origin
               (method url-fetch)
@@ -223,8 +228,6 @@ (define-public slurm
                   (mkdir "contribs")
                   (rename-file "tmp-pmi" "contribs/pmi")
                   (rename-file "tmp-pmi2" "contribs/pmi2")))))
-    ;; FIXME: More optional inputs could be added,
-    ;; in particular mysql and gtk+.
     (inputs (list freeipmi
                   `(,hwloc-2 "lib")
                   json-c
@@ -291,6 +294,35 @@ (define-public slurm
                     "https://github.com/SchedMD/slurm/blob/master/contribs/pmi2/COPYRIGHT")
                    license:gpl2+))))   ; the rest, often with OpenSSL exception
 
+(define (make-slurm base-slurm)
+  "Make a slurm package with all optional features enabled. Base it off of the
+minimal slurm package BASE-SLURM."
+  (package
+    (inherit base-slurm)
+    (name "slurm")
+    (arguments
+     (substitute-keyword-arguments (package-arguments base-slurm)
+       ((#:configure-flags flags #~'())
+        #~(cons* "--enable-slurmrestd"
+                 (string-append "--with-bpf="
+                                (dirname
+                                 (dirname (search-input-directory
+                                           %build-inputs "include/linux"))))
+                 (string-append "--with-http-parser="
+                                #$(this-package-input "http-parser"))
+                 (string-append "--with-rdkafka="
+                                #$(this-package-input "librdkafka"))
+                 (string-append "--with-yaml="
+                                #$(this-package-input "libyaml"))
+                 #$flags))))
+    ;; FIXME: More optional inputs could be added.
+    (inputs
+     (modify-inputs (package-inputs base-slurm)
+       (prepend dbus freeipmi http-parser
+                libjwt librdkafka libyaml (list mariadb "dev"))))))
+
+(define-public slurm (make-slurm slurm-minimal))
+
 ;; The SLURM client/daemon protocol and file format changes from time to time
 ;; in incompatible ways, as noted in
 ;; <https://slurm.schedmd.com/troubleshoot.html#network>.  Thus, keep older
@@ -298,9 +330,9 @@ (define-public slurm
 ;; As noted in the link, YY.MM is the release scheme, and the 'maintenance'
 ;; digit does not introduce incompatibilities.
 
-(define-public slurm-23.02
+(define-public slurm-minimal-23.02
   (package
-   (inherit slurm)
+   (inherit slurm-minimal)
    (version "23.02.6")
     (source (origin
              (inherit (package-source slurm))
@@ -314,12 +346,14 @@ (define-public slurm-23.02
               (base32
                "08rz3r1rlnb3pmfdnbh542gm44ja0fdy8rkj4vm4lclc48cvqp2a"))))))
 
-(define-public slurm-22.05
+(define-public slurm-23.02 (make-slurm slurm-minimal-23.02))
+
+(define-public slurm-minimal-22.05
   (package
-    (inherit slurm-23.02)
+    (inherit slurm-minimal-23.02)
     (version "22.05.1")
     (source (origin
-              (inherit (package-source slurm-23.02))
+              (inherit (package-source slurm-minimal-23.02))
               (method url-fetch)
               (uri (string-append
                     "https://download.schedmd.com/slurm/slurm-"
@@ -329,12 +363,14 @@ (define-public slurm-22.05
                (base32
                 "0f3hhlki8g7slllsnyj1qikbsvr62i0hig85lcdcfnmsagzlhbyi"))))))
 
-(define-public slurm-21.08
+(define-public slurm-22.05 (make-slurm slurm-minimal-22.05))
+
+(define-public slurm-minimal-21.08
   (package
-    (inherit slurm-22.05)
+    (inherit slurm-minimal-22.05)
     (version "21.08.8")
     (source (origin
-              (inherit (package-source slurm-22.05))
+              (inherit (package-source slurm-minimal-22.05))
               (method url-fetch)
               (uri (string-append
                     "https://download.schedmd.com/slurm/slurm-"
@@ -346,15 +382,17 @@ (define-public slurm-21.08
 
     ;; This and older versions of slurm have PMIx support but they seem to
     ;; require an older version of openpmix.  Disable PMIx support.
-    (inputs (modify-inputs (package-inputs slurm-22.05)
+    (inputs (modify-inputs (package-inputs slurm-minimal-22.05)
               (delete "openpmix")))))
 
-(define-public slurm-20.11
+(define-public slurm-21.08 (make-slurm slurm-minimal-21.08))
+
+(define-public slurm-minimal-20.11
   (package
-    (inherit slurm-21.08)
+    (inherit slurm-minimal-21.08)
     (version "20.11.9")
     (source (origin
-              (inherit (package-source slurm-21.08))
+              (inherit (package-source slurm-minimal-21.08))
               (method url-fetch)
               (uri (string-append
                     "https://download.schedmd.com/slurm/slurm-"
@@ -364,12 +402,14 @@ (define-public slurm-20.11
                (base32
                 "0xq2d6dm285y541dyg1h66z7svsisrq8c81ag0f601xz1cn3mq9m"))))))
 
-(define-public slurm-20.02
+(define-public slurm-20.11 (make-slurm slurm-minimal-20.11))
+
+(define-public slurm-minimal-20.02
   (package
-    (inherit slurm-20.11)
+    (inherit slurm-minimal-20.11)
     (version "20.02.6-1")
     (source (origin
-              (inherit (package-source slurm-20.11))
+              (inherit (package-source slurm-minimal-20.11))
               (method url-fetch)
               (uri (string-append
                     "https://download.schedmd.com/slurm/slurm-"
@@ -379,17 +419,19 @@ (define-public slurm-20.02
                (base32
                 "0qj4blfymrd2ry2qmb58l3jbr4jwygc3adcfw7my27rippcijlyc"))))
     (arguments
-     (substitute-keyword-arguments (package-arguments slurm-20.11)
+     (substitute-keyword-arguments (package-arguments slurm-minimal-20.11)
        ((#:configure-flags flags ''())
         #~(append '("CFLAGS=-O2 -g -fcommon" "LDFLAGS=-fcommon")
                   #$flags))))))
 
-(define-public slurm-19.05
+(define-public slurm-20.02 (make-slurm slurm-minimal-20.02))
+
+(define-public slurm-minimal-19.05
   (package
-    (inherit slurm-20.02)
+    (inherit slurm-minimal-20.02)
     (version "19.05.8")
     (source (origin
-              (inherit (package-source slurm-20.02))
+              (inherit (package-source slurm-minimal-20.02))
               (method url-fetch)
               (uri (string-append
                     "https://download.schedmd.com/slurm/slurm-"
@@ -399,14 +441,16 @@ (define-public slurm-19.05
                (base32
                 "10c9j4a9a6d4ibpf75006mn03p8xgpaprc247x2idakysjf2fw43"))))))
 
+(define-public slurm-19.05 (make-slurm slurm-minimal-19.05))
+
 ;; Same as Debian 10
-(define-public slurm-18.08
+(define-public slurm-minimal-18.08
   (package
-    (inherit slurm-19.05)
+    (inherit slurm-minimal-19.05)
     (version "18.08.9")
     (source
       (origin
-        (inherit (package-source slurm-20.02))
+        (inherit (package-source slurm-minimal-20.02))
         (uri (string-append
                "https://download.schedmd.com/slurm/slurm-"
                version ".tar.bz2"))
@@ -415,6 +459,8 @@ (define-public slurm-18.08
          (base32
           "1bgrpz75m7l4xhirsd0fvnkzlkrl8v2qpmjcz60barc5qm2kn457"))))))
 
+(define-public slurm-18.08 (make-slurm slurm-minimal-18.08))
+
 (define-public slurm-drmaa
   (package
     (name "slurm-drmaa")

base-commit: 2394a7f5fbf60dd6adc0a870366adb57166b6d8b
-- 
2.45.2