guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

03/03: system: Warn when multiple nss-certs packages are used.


From: guix-commits
Subject: 03/03: system: Warn when multiple nss-certs packages are used.
Date: Fri, 26 Apr 2024 07:07:56 -0400 (EDT)

apteryx pushed a commit to branch master
in repository guix.

commit 9593750698394b6fecd73e7fca00409ea1ffa2e3
Author: Maxim Cournoyer <maxim.cournoyer@gmail.com>
AuthorDate: Wed Apr 24 16:49:03 2024 -0400

    system: Warn when multiple nss-certs packages are used.
    
    This can happen due to users providing 'nss-certs' and adding it to the
    %base-packages, which now include 'nss-certs'.
    
    * gnu/system.scm (operating-system-packages): Warn when multiple nss-certs
    packages are detected; keep only the latest one.
    
    Change-Id: I6104f134ea1cc155ae9e8e0ae70bb5a38fc05800
    Reported-by: Ian Eure <ian@retrospec.tv>
---
 gnu/system.scm | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/gnu/system.scm b/gnu/system.scm
index c7f8003ad2..025834328c 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -43,7 +43,8 @@
   #:use-module (guix deprecation)
   #:use-module (guix derivations)
   #:use-module (guix profiles)
-  #:use-module ((guix utils) #:select (substitute-keyword-arguments))
+  #:use-module ((guix utils) #:select (substitute-keyword-arguments
+                                       version>?))
   #:use-module (guix i18n)
   #:use-module (guix diagnostics)
   #:use-module (guix ui)
@@ -275,7 +276,7 @@ VERSION is the target version of the boot-parameters 
record."
   (issue operating-system-issue                   ; string
          (default %default-issue))
 
-  (packages operating-system-packages             ; list of (PACKAGE OUTPUT...)
+  (packages %operating-system-packages            ; list of (PACKAGE OUTPUT...)
             (default %base-packages))             ; or just PACKAGE
 
   (timezone operating-system-timezone
@@ -316,6 +317,29 @@ VERSION is the target version of the boot-parameters 
record."
   hosts-service-type
   (%operating-system-hosts-file os))
 
+;;; XXX: Remove after a new release of Guix no longer suggests to install
+;;; nss-certs.
+(define (operating-system-packages os)
+  "Return the packages of the OS <operating-system> record object."
+  ;; This wrapper is used to warn users that their operating system packages
+  ;; field contains a duplicated nss-certs packages.
+  (let* ((packages (%operating-system-packages os))
+         (nss-certs-packages (sort (filter (lambda (p)
+                                             (string=? "nss-certs" 
(package-name p)))
+                                           packages)
+                                   (lambda (x y)
+                                     ;; Sort from newer to older versions.
+                                     (version>? (package-version x)
+                                                (package-version y))))))
+    (if (> (length nss-certs-packages) 1)
+        (begin
+          (warning #f
+                   (G_ "multiple 'nss-certs' packages found; 'nss-certs' \
+is now included by default in '%base-packages'; ensure it is not explicitly \
+listed in the operating system 'packages' field~%"))
+          (fold delete packages (drop nss-certs-packages 1)))
+        packages)))
+
 (define* (operating-system-kernel-arguments
           os root-device #:key (version %boot-parameters-version))
   "Return all the kernel arguments, including the ones not specified directly



reply via email to

[Prev in Thread] Current Thread [Next in Thread]