Subject: [PATCH v2 1/2] gnu: services: nscd: Add nsncd optional support.

From: Nicolas Graves <[email-masked]>
Date: Sun, 29 Jun 2025 13:52:40 +0200

From: Picnoir <[email-masked]>

Add nsncd optional support for nscd-configuration.

* gnu/services/base.scm (<nscd-configuration>): Add implementation field.
  (nscd-shepherd-service-type)[start]: Update forkexec-constructor
  accordingly.

Change-Id: I73d03bd149ff005130e1ed2532e1b4b0e3d572f5
---
 gnu/services/base.scm | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 88dbcbf72a..a81bdf809c 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -84,6 +84,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
@@ -1365,6 +1366,8 @@ (define-deprecated (mingetty-service config)
 (define-record-type* <nscd-configuration> nscd-configuration
   make-nscd-configuration
   nscd-configuration?
+  (implementation nscd-implementation
+                  (default 'glibc))               ;'glibc or 'nsncd
   (log-file    nscd-configuration-log-file        ;string
                (default #f))
   (debug-level nscd-debug-level                   ;integer
@@ -1543,12 +1546,20 @@ (define (nscd-shepherd-service config)
            (requirement '(user-processes syslogd))
 
            (start #~(make-forkexec-constructor
-                     (list #$nscd "-f" #$nscd.conf "--foreground")
+                     #$(match (nscd-implementation config)
+                         ('glibc
+                          #~(list #$nscd "-f" #$nscd.conf "--foreground"))
+                         ('nsncd
+                          #~(list #$(file-append nsncd "/bin/nsncd"))))
 
-                     ;; 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"
+                     #$@(match (nscd-implementation config)
+                          ('glibc
+                           ;; 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"))
+                          ('nsncd
+                           #~()))
 
                      #:environment-variables
                      (list (string-append "LD_LIBRARY_PATH="
-- 
2.49.0