Subject: [bug#71064] [PATCH 7/7] gnu: services: nscd: add Nsncd optional support.

From: [email-masked]
Date: Sun, 19 May 2024 14:46:27 +0200

From: Picnoir <[email-masked]>

* gnu/services/base.scm (services: nscd: add Nsncd optional support): Add a
new nscd-use-nscd? field in the Nscd configuration record. When set to #t, the
nscd service will use Nsncd in place of the Glibc's Nscd. I'm not 100% sure
adding this to the existing Nscd service is a good idea, it's however the most
convenient option for now. Or is it? :)

Change-Id: I73d03bd149ff005130e1ed2532e1b4b0e3d572f5
---
 gnu/services/base.scm | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 85160bd3ab..66306384c0 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -79,6 +79,7 @@ (define-module (gnu services base)
                 #:select (bcachefs-tools exfat-utils jfsutils zfs))
   #:use-module (gnu packages fonts)
   #:use-module (gnu packages terminals)
+  #:use-module (gnu packages nss)
   #:use-module ((gnu packages wm) #:select (sway))
   #:use-module ((gnu build file-systems)
                 #:select (mount-flags->bit-mask
@@ -1284,6 +1285,8 @@ (define-deprecated (mingetty-service config)
 (define-record-type* <nscd-configuration> nscd-configuration
   make-nscd-configuration
   nscd-configuration?
+  (use-nsncd?  nscd-use-nsncd?                     ;boolean
+               (default #t))
   (log-file    nscd-configuration-log-file        ;string
                (default "/var/log/nscd.log"))
   (debug-level nscd-debug-level                   ;integer
@@ -1447,12 +1450,14 @@ (define (nscd-shepherd-service config)
            (requirement '(user-processes syslogd))
 
            (start #~(make-forkexec-constructor
-                     (list #$nscd "-f" #$nscd.conf "--foreground")
+                     #$(if (nscd-use-nsncd? config)
+                         #~(list #$(file-append nsncd "/bin/nsncd"))
+                         #~(list #$nscd "-f" #$nscd.conf "--foreground"))
 
                      ;; Wait for the PID file.  However, the PID file is
                      ;; written before nscd is actually listening on its
                      ;; socket (XXX).
-                     #:pid-file "/var/run/nscd/nscd.pid"
+                     #$@(if (nscd-use-nsncd? config) '() '(#:pid-file  "/var/run/nscd/nscd.pid"))
 
                      #:environment-variables
                      (list (string-append "LD_LIBRARY_PATH="
-- 
2.41.0