[bug#71064,v2,1/2] gnu: services: nscd: Add nsncd optional support.

Message ID 20250629115447.16729-2-ngraves@ngraves.fr
State New
Headers
Series nscd: Add nsncd optional support. |

Commit Message

Nicolas Graves June 29, 2025, 11:52 a.m. UTC
From: Picnoir <picnoir@alternativebit.fr>

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(-)
  

Comments

Ludovic Courtès July 16, 2025, 9:46 p.m. UTC | #1
Hi Nicolas and Picnoir,

Apologies for the long delay.

Nicolas Graves <ngraves@ngraves.fr> writes:

> From: Picnoir <picnoir@alternativebit.fr>
>
> 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

I think the two patches can be squashed (with you as co-author,
Nicolas).

It LGTM, except for two things:

  1. The ‘implementation’ field should be documented.

  2. The ‘glibc’ field should probably be renamed to ‘package’ (the name
     conventionally used for fields like this), with a compatibility
     shim (info "(guix) Deprecation Policy").

Are you willing/able to help with this?

I’m about to be offline for summer vacation but let me know if you’d
rather share the workload.

Thanks,
Ludo’.
  

Patch

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="